我使用以下查询来获取 OrderID:
SELECT OrderItem.ID
, ProductID
, OrderID
, Quantity
, P.Title
, P.CurrentPrice
, P.ID
, (P.CurrentPrice* OrderItem.Quantity) AS Total
FROM OrderItem
INNER JOIN Product AS P
ON OrderItem.ProductID = P.ID
如何获取每个 OrderID 的总金额(将所有具有相同 OrderID 的总计相加)?
最佳答案
您可以使用选择表单进行选择和分组
select OrderID, sum(Total)
from (
SELECT
OrderItem.ID
, ProductID
, OrderID
, Quantity
, P.Title
,P.CurrentPrice
, P.ID
, (P.CurrentPrice* OrderItem.Quantity) AS Total
FROM OrderItem
INNER JOIN Product AS P ON OrderItem.ProductID = P.ID
) t
group by OrderId
关于sql - 如何在 MS Access SQL 中获取总量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44596501/