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

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

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

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


God

God

SELECT SalesTerritoryID,
ProductID,
AVG(UnitPrice),
MAX(OrderQty)
MAX(DiscountAmount)
FROM Sales.Details
GROUP BY SalesTerritoryID, ProductID
ORDER BY SalesTerritoryID DESC, ProductID DESC

Paul

Paul

Not very well worder as far as “English Language” is concerned, it is hard to destinguish whether they mean both columns descending or just SalesTerritoryID when they say…
“Orders the results in descending order by SalesTerritorylD and then by ProductlD.”

ray

ray

Then mean both in Decending. It means you order SalesTerritoryID first in descending reason why you see the DESC after SalesTerritoryID, and then another DESC after ProductID at the end of the query.