SQL query to retrieve SUM in various DATE ranges

前端 未结 3 2027
天涯浪人
天涯浪人 2021-01-14 08:09

I have a table with information about sold products, the customer, the date of the purchase and summary of sold units.

The result I am trying to get should be 4 rows

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-14 09:09

    I would go with the following

    SELECT SUM(totalprice), year(date), month(date) 
    FROM sales
    GROUP BY year(date), month(date)
    

提交回复
热议问题