PrepAway - Latest Free Exam Questions & Answers

You need to create a query that meets the following req…

You have a database named Sales that contains the tables as shown in the exhibit.

You need to create a query that meets the following requirements:
– References columns by using one-part names only.
– Groups aggregates by SalesTerritorylD, and then by ProductlD.
– Orders the results in descending order by SalesTerritorylD and then by
ProductlD.
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 SalesTerritoryID,
ProductID,
AVG(UnitPrice),
MAX(OrderQty),
MAX(DiscountAmount)
FROM Sales.Details
GROUP BY SalesTerritoryID, ProductID
ORDER BY SalesTerritoryID DESC, ProductID DESC


Leave a Reply