When referencing columns in a table.

CORRECT TEXT
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.


microsoft-exams

2 thoughts on “When referencing columns in a table.

  1. SELECT C.LastName,
    MAX(O.OrderDate) As MostRecentOrderDate
    FROM Sales.Customers AS C inner join Sales.Orders as O
    ON C.CustomerID = O.CustomerID
    GROUP BY CustomerID
    ORDER BY MostRecentOrderDate DESD

  2. SELECT C.LastName, MAX(O.OrderDate) AS MostRecentOrderDate
    FROM Sales.Customers As C INNER JOIN Sales.Orders AS O ON C.CustomerID = O.CustomerID
    GROUP BY C.LastName
    ORDER BY MostRecentOrderDate DESC ;

Leave a Reply

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


The reCAPTCHA verification period has expired. Please reload the page.