Which code segment should you use?

You have a database 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.
• Return the most recent orders first.
• 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.
• Return the order date in a column named MostRecentOrderDate that appears as the last column in the report.
The solution must support the ANSI SQL-99 standard.
Which code segment should you use?
To answer, type the correct code in the answer area.
A. SELECT c.CustomerID -- optional
c.LastName, max(o.OrderDate) ‘MostRecentOrderDate’
FROM Customer c LEFT OUTER JOIN Orders o ON o.CustomerID = c.CustomerID
GROUP BY c.CustomerID, c.LastName
ORDER BY 3 DESC
B. select C.Lastname, P.MostRecentOrderDate
from customers AS C inner join
(
select customID, MostRecentOrderDate=max(orderDate) from orders group by customID
) P
on C.customerID=P.CustomerID
order by P.MostRecentOrderDate desc
C. SELECT C.LastName, O.OrderDate AS MostRecentOrderDate
FROM Customers AS C INNER JOIN Orders AS O
ON C.CustomerID = O.CustomerID
ORDER BY O.OrderDate DESC

microsoft-exams

Leave a Reply

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


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