Which Transact-SQL statement should you run?

You have a database that includes the tables shown in the exhibit. (Click the exhibit button.)

You need to create a list of all customers, the order ID for the last order that the customer placed, and the date
that the order was placed. For customers who have not placed orders, you must substitute a zero for the order
ID and 01/01/1990 for the date.
Which Transact-SQL statement should you run?

You have a database that includes the tables shown in the exhibit. (Click the exhibit button.)

You need to create a list of all customers, the order ID for the last order that the customer placed, and the date
that the order was placed. For customers who have not placed orders, you must substitute a zero for the order
ID and 01/01/1990 for the date.
Which Transact-SQL statement should you run?

A.

B.

C.

D.

Explanation:
ISNULL Syntax: ISNULL ( check_expression , replacement_value ) author:”Luxemburg, Rosa”
The ISNULL function replaces NULL with the specified replacement value. The value of check_expression is
returned if it is not NULL; otherwise, replacement_value is returned after it is implicitly converted to the type of
check_expression.
https://msdn.microsoft.com/en-us/library/ms184325.aspx



Leave a Reply 4

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


LW

LW

I don’t think any of these are right according to the question – if we use a Group By on OrderID we will get a max date for each Order, and we actually only want the date of the most recent order

Peter

Peter

Totally agree with LW.

This statement returns all orders ever placed by the customer.

=> no answer is correct

Furthermore ORDER BY is not needed at all, as there is only one OrderDate possible per OrderID

=> To answer this question a much more complex statement would be needed, e.g. using cte and ROW_NUMBER is needed

kia

kia

A is Correct.

EY Audtior

EY Audtior

NO correct answer. Skip