PrepAway - Latest Free Exam Questions & Answers

You need to create a query for a report

You have a database named Sales that contains the tables shown in the exhibit. (Click the Exhibit button).

You need to create a query for a report. The query must meet the following requirements:
NOT use object delimiters.
Use the first initial of the table as an alias.
Return the most recent order date for each customer.
Retrieve the last name of the person who placed the order.
The solution must support the ANSI SQL-99 standard. Part of the correct T-SQL statement has been provided in the answer area. Provide the complete code.

PrepAway - Latest Free Exam Questions & Answers

Answer: See the explanation

Explanation:
SELECT C.LastName, MAX(O.OrderDate) AS MostRecentOrderDate FROM Customers AS C INNER JOIN Orders AS O ON
C
CustomerID=O.CustomerID GROUP BY C.Lastname ORDER BY MAX (O.OrderDate) DESC

3 Comments on “You need to create a query for a report


Leave a Reply