SQL Selecting multiple sums?

后端 未结 5 2164
无人及你
无人及你 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:39

    You could use GROUP BY to split up the Sales based on date. In Oracle you could say:

    select count(*)
          ,case when order_date >= '01/01/09' then 'after' else 'before' end
    from   log 
    group by case when order_date >= '01/01/09' then 'after' else 'before' end;
    

提交回复
热议问题