0

i want to calculate the sum of the money i spent on the based on two specific dates, i have tried doing this using several queires but none of them seem to work. Below are the table and the query respectively,

     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

2 Answers 2

1
SELECT SUM(price) AS TotalPrice 
FROM orders
WHERE OrderDate >= '2015-01-05' AND OrderDate <= '2015-01-16'

or

SELECT SUM(price) AS TotalPrice 
FROM orders
WHERE OrderDate between '2015-01-05' AND '2015-01-16'
Sign up to request clarification or add additional context in comments.

Comments

0

Change

HAVING OrderDate >='2015-01-05' AND <= '2015-01-16'

To

WHERE OrderDate >='2015-01-05' OrderDate AND <= '2015-01-16'

1 Comment

having is actually rather for the use of group by

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.