Total sales per month

前端 未结 4 513
时光取名叫无心
时光取名叫无心 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:14

    Another solution is to calculate the first day of the month

    Select DateAdd(d,DateDiff(d,0,[Date])-DatePart(d,[Date])+1,0)
        , Sum( Price )
    From Sales
    Group By DateAdd(d,DateDiff(d,0,[Date])-DatePart(d,[Date])+1,0)
    

提交回复
热议问题