我想根据两个特定的日期计算我花在基金上的钱的总和,我已经尝试使用几个queires这样做,但它们似乎都没有效果。下面分别是表格和查询
Product_ID----ProductName------price------OrderDate
--- 1 -------- Chair -------- 7 ------ 2015-01-05
--- 2 -------- Lamp --------- 14 ----- 2015-01-16
--- 3 -------- Table -------- 9 ------ 2015-02-25
SELECT SUM(price) AS TotalPrice FROM orders
HAVING OrderDate >='2015-01-05' AND <= '2015-01-16'
答案 0 :(得分:1)
SELECT SUM(price) AS TotalPrice
FROM orders
WHERE OrderDate >= '2015-01-05' AND OrderDate <= '2015-01-16'
或
SELECT SUM(price) AS TotalPrice
FROM orders
WHERE OrderDate between '2015-01-05' AND '2015-01-16'
答案 1 :(得分:0)
更改
HAVING OrderDate >='2015-01-05' AND <= '2015-01-16'
要
WHERE OrderDate >='2015-01-05' OrderDate AND <= '2015-01-16'