You need to create a query that meets the following requirements: References columns by using one-part names only

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

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

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 0

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