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.
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.
SELECT Sale_Date, SUM(Sale_Price)
FROM sales
WHERE Sale_Date < DATE '2015-10-12'
GROUP BY Sale_Date
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With