PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You have a database that contains the tables shown in the exhibit. (Click the Exhibit button.)

You need to create a query that calculates the total sales of each OrderId from the Sales.Details table. The solution must meet the following requirements:
Use one-part names to reference columns.
Sort the order of the results from OrderId.

NOT depend on the default schema of a user.
Use an alias of TotalSales for the calculated ExtendedAmount.
Display only the OrderId column and the calculated TotalSales column.
Which code segment should you use? To answer, type the correct code in the answer area.

PrepAway - Latest Free Exam Questions & Answers

Answer: See the explanation

Explanation:
SELECT OrderID, SUM(ExtendedAmount) AS TotalSales FROM Sales.Details GROUP BY OrderID ORDER BY OrderID

2 Comments on “Which code segment should you use?

  1. overkill says:

    “NOT depend on the default schema of a user.”

    Im Assuming this means that you have to put the table in two part name format to avoid confusion with other tables of the user schema.

    I think is this




    3



    0

Leave a Reply