3

I am trying to get the sum of all sale prices before a specified date, I have tried the following.

SELECT SUM (Sale_Price), Sale_Date
FROM sales
GROUP BY Sale_Price, Sale_Date
WHERE Sale_Date < '2015-10-12';

However I keep getting "SQL command not properly ended". Any help would be greatly appreciated.

2 Answers 2

4

If you want the sum for all the dates, then you would use:

SELECT SUM(Sale_Price)
FROM sales
WHERE Sale_Date < DATE '2015-10-12';

You only need the GROUP BY if you want one row for each dae.

Sign up to request clarification or add additional context in comments.

Comments

3
SELECT Sale_Date, SUM(Sale_Price)
FROM sales 
WHERE Sale_Date < DATE '2015-10-12'
GROUP BY Sale_Date 

2 Comments

"literal does not match format string" I am using the DATE format in the DB, entered in the YYYY-MM-DD format.
Try DATE '2015-10-12'

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.