Solution: You run the following Transact-SQL statement:…

Note: This question is part of a series of questions that present the same scenario. Each question in
the series contains a unique solution that might meet the stated goals. Some question sets might have
more than one correct solution, while others might not have a correct solution.
After you answer a question in this section. You will NOT be able to return to it. As a result, these
questions will not appear in the review screen.
You have a database that includes the tables shown in the exhibit (Click the Exhibit button.)

You need to create a Transact-SQL query that returns the following information:
the customer number
the customer contact name
the date the order was placed, with a name of DateofOrder
a column named Salesperson, formatted with the employee first name, a space, and the employee last
name
orders for customers where the employee identifier equals 4
The output must be sorted by order date, with the newest orders first.
The solution must return only the most recent order for each customer.
Solution: You run the following Transact-SQL statement:

Does the solution meet the goal?

Note: This question is part of a series of questions that present the same scenario. Each question in
the series contains a unique solution that might meet the stated goals. Some question sets might have
more than one correct solution, while others might not have a correct solution.
After you answer a question in this section. You will NOT be able to return to it. As a result, these
questions will not appear in the review screen.
You have a database that includes the tables shown in the exhibit (Click the Exhibit button.)

You need to create a Transact-SQL query that returns the following information:
the customer number
the customer contact name
the date the order was placed, with a name of DateofOrder
a column named Salesperson, formatted with the employee first name, a space, and the employee last
name
orders for customers where the employee identifier equals 4
The output must be sorted by order date, with the newest orders first.
The solution must return only the most recent order for each customer.
Solution: You run the following Transact-SQL statement:

Does the solution meet the goal?

A.
Yes

B.
No

Explanation:
We should use a WHERE clause, not a HAVING clause. The HAVING clause would refer to aggregate data.



Leave a Reply 7

Your email address will not be published. Required fields are marked *


scotrid

scotrid

answer is YES it does meet the goal !

davgmane

davgmane

Answer is Yes. Having is used with a group by, which is ok. Also being used with an aggregate MAX.

Peter

Peter

No is correct!

Running this script will result in an syntax error:

“Column ‘o.empid’ is invalid in the HAVING clause because it is not contained in either an aggregate function or the GROUP BY clause.”

If it would be HAVING MAX(o.empid) = 4 than it would run successfully but this is not given.

Please see also example code below:

kia

kia

o.empid is in group by clouse.
Answer is Yes.

EY Auditor

EY Auditor

Answer should A Yes. o.empid is in group by clouse.

EY Auditor

EY Auditor

o.empid is not in the select statement. this will fail.