You have a database named Sales that contains the tables as shown in the exhibit. (Click the Exhibit button.)
You need to create a query for a report. The query must meet the following requirements:
✑ Return the last name of the customer who placed the order.
✑ Return the most recent order date for each customer.
✑ Group the results by CustomerID.
✑ Order the results by the most recent OrderDate.
✑ Use the database name and table name for any table reference.
✑ Use the first initial of the table as an alias when referencing columns in a table.
The solution must support the ANSI SQL-99 standard and must NOT use object identifiers.
Part of the correct T-SQL statement has been provided in the answer area. Complete the
SQL statement.
Answer:
SELECT o.LastName,
MAX (o.OrderData) AS MostRecentOrderData
FROM Sales.Orders AS o
GROUP BY o.CustomerID
ORDER BY o.OrderDate DESC
No comments:
Post a Comment