Total sales per month

前端 未结 4 534
时光取名叫无心
时光取名叫无心 2021-02-05 10:20

I think this is common, is it?

If you have a table with SALES {Customer_ID, Price, SmallDateTime date}. How do you report all sales per month?



        
4条回答
  •  深忆病人
    2021-02-05 11:03

    SELECT CONVERT(CHAR(7), SmallDateTime, 120) as Year_Month,
           SUM(Price)
        FROM Sales
        GROUP BY CONVERT(CHAR(7), SmallDateTime, 120) 
        ORDER BY Year_Month
    

提交回复
热议问题