PrepAway - Latest Free Exam Questions & Answers

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

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.

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

3 Comments on “You need to create a query that meets the following requirements: References columns by using one-part names o

  1. God says:

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




    0



    0
  2. Paul says:

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




    0



    0
  3. ray says:

    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.




    0



    0

Leave a Reply