Answer :
Answer alongwith Explanation:
The following is the statement that uses an aggregate window function in order to get the total amount of each order.
SELECT isnull(p1.PName,'Total') As PName,
Sum((t1.Price minus t1.Discount ) multiply with Quantity) AS TotalAmount
FROM Products AS t1
JOIN OrderItems AS t2
ON t1.ProductID = t2.ProductID
GROUP BY Rollup(PName) ORDER BY order id ASC
Thus, it can be used for the function.