SQL Selecting multiple sums?

后端 未结 5 2090
无人及你
无人及你 2021-02-08 17:00

Let\'s say I have a table:

SELECT  SUM(quantity) AS items_sold_since_date,
        product_ID
FROM    Sales
WHERE order_date >= \'01/01/09\'
GROUP BY product_         


        
5条回答
  •  再見小時候
    2021-02-08 17:34

    something like this?:

    SELECT  SUM(quantity) AS items_sold_since_date,
            total_items_sold = (SELECT SUM(quantity) from Sales GROUP BY product_ID),
            product_ID
    FROM    Sales
    WHERE order_date >= '01/01/09'
    GROUP BY product_ID
    

提交回复
热议问题