我想添加所有金额作为总计...请帮我如何写一个查询

时间:2015-09-10 06:23:17

标签: mysql sql ms-access

这是我的查询。我想做金额的总和......但我没有得到如何得到全额的总和。请帮帮我。

SELECT AllocateAsset.Item, AllocateAsset.ItemModel,
    COUNT(AllocateAsset.ItemModel) AS CountOfItem,
    (CountOfItem * (
        SELECT Rate
        FROM rateList
        WHERE rateList.MakeModel = AllocateAsset.ItemModel
                   )
    ) / 4 AS Amount , SUM(Amount) AS Total
FROM aboutPM INNER JOIN
(
    AllocateAsset INNER JOIN PMReport
    ON AllocateAsset.ID=PMReport.AssetID
)
ON aboutPM.ID = PMReport.AboutPMID
WHERE (((aboutPM.Year)="2015") AND ((aboutPM.Period)="Jan-Feb-Mar"))
GROUP BY AllocateAsset.Item, AllocateAsset.ItemModel, CountOfItem, Amount
ORDER BY AllocateAsset.Item

1 个答案:

答案 0 :(得分:0)

Group by列表

中删除金额列
GROUP BY AllocateAsset.Item, AllocateAsset.ItemModel, CountOfItem, Amount