PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You have a database that contains the tables as shown in the exhibit. (Refer to the Exhibit.)

You have the following query:

You need to recreate the query to meet the following requirements:
Reference columns by using one-part names only.
Sort aggregates by SalesTerritoryID, and then by ProductID.
Order the results in descending order from SalesTerritoryID to ProductID.
The solution must use the existing SELECT clause and FROM clause.
Which code segment should you use?
To answer, type the correct code in the answer area.

A.

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

One Comment on “Which code segment should you use?

  1. salim says:

    answer is

    SELECT SALESTERRITORYID,
    PRODUCTID,
    AVG(UNITPRICE),
    MAX(ORDERQTY),
    MAX(DISCOUNTAMOUNT)
    FROM SALES.DETAILS
    GROUP BY SALESTERRITORYID,PRODUCTID
    –Sort aggregates by SalesTerritoryID, and then by ProductID.
    –Order the results in descending order from SalesTerritoryID to ProductID.
    ORDER BY SALESTERRITORYID DESC, PRODUCTID DESC




    0



    0

Leave a Reply