I don't follow exactly what you want to do. However, your query would more colloquially and accurately be written using JOIN
. If you want the total per order then you don't want all those extraneous columns on the row:
SELECT ol.OrderId,
SUM((ol.OrderedQuantity * p.ProductStandardPrice) AS TotalAmount
FROM orderline_t ol JOIN
product_t p
ON p.ProductID = ol.ProductID
GROUP BY ol.Order;
I suspect that starting with a working query will get you closer to the solution you want.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…