SQL Selecting multiple sums?
SELECT SUM(CASE WHEN order_date >= '01/01/09' THEN quantity ELSE 0 END) AS items_sold_since_date, SUM(quantity) AS items_sold_total, product_IDFROM SalesGROUP BY product_ID
something like this?:
SELECT SUM(quantity) AS items_sold_since_date, total_items_sold = (SELECT SUM(quantity) from Sales GROUP BY product_ID), product_IDFROM SalesWHERE order_date >= '01/01/09'GROUP BY product_ID
If you like to see total sales alongside, then you would use sum(sale_amt), and in the group by add the sale_amt. I hope it helps.