You need to create a query that calculates the total sales of each OrderlD from a table named Sales.Details

CORRECT TEXT
You need to create a query that calculates the total sales of each OrderlD from a table named
Sales.Details. The table contains two columns named OrderlD and ExtendedAmount.
The solution must meet the following requirements:
Use one-part names to reference columns.
Start the order of the results from OrderlD.
NOT depend on the default schema of a user.
Use an alias of TotalSales for the calculated ExtendedAmount.
Display only the OrderlD column and the calculated TotalSales column.
Provide the correct code in the answer area.

CORRECT TEXT
You need to create a query that calculates the total sales of each OrderlD from a table named
Sales.Details. The table contains two columns named OrderlD and ExtendedAmount.
The solution must meet the following requirements:
Use one-part names to reference columns.
Start the order of the results from OrderlD.
NOT depend on the default schema of a user.
Use an alias of TotalSales for the calculated ExtendedAmount.
Display only the OrderlD column and the calculated TotalSales column.
Provide the correct code in the answer area.

Answer: See the explanation

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



Leave a Reply 2

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


Peter

Peter

select OrderID, SUM(ExtendedAmount) as TotalSales
from Sales.Details
group by OrderID
order by OrderID

Dan

Dan

no need to include order by OrderID.

“Start the order of the results from OrderlD.” – means OrderID will be the firts column