0
我得到這個SQL查詢Calc的訂單和訂單項目,其中包含產品
declare @ProductNo int
set @ProductNo = 123
select o.OrderNo, OrderDate, ol.Amount
from OrderLine ol
inner join [Order] o on ol.OrderNo = o.OrderNo
where ol.ProductNo = @ProductNo
現在的問題是,我想回一筆每個訂單。 我tryid改變我的查詢
select o.OrderNo, OrderDate, ol.Amount,(select sum(ol.Amount * ol.UnitPrice) as OrderTotal from OrderLine oll where oll.OrderNo = o.OrderNo)
from OrderLine ol
inner join [Order] o on ol.OrderNo = o.OrderNo
where ol.ProductNo = @ProductNo
,但是這不是跑步,所以我希望有人可以幫我完成我的查詢