我需要一个MySQL查询,它将在日期范围之间选择记录,将每个结果的'Qty'列和'unit price'列相乘,然后将所有这些结果一起添加。我也需要有正确语法的帮助。
这样的事情:
SELECT 'Qty','unit value'
FROM `Inventory` (Qty * unit value for each result) then (add all results together)
WHERE `Date Received` BETWEEN '2012-1-1' AND '2013-1-1'
任何帮助表示赞赏!
答案 0 :(得分:1)
你在找这样的东西吗?
SELECT SUM(Qty * UnitValue) total
FROM Inventory
WHERE DateReceived BETWEEN '2012-01-01' AND '2013-01-01'
这是 SQLFiddle 演示