sql统计当天,本周,本月问题
能否一条语句统计出天,周,月的数据?
select 名字,count(数量) as 月 from 表1 where datediff(month,A.STARTTIME,getdate())=0 group by 名字
select 名字,count(数量) as 周 from 表1 where datediff(week,A.STARTTIME,getdate())=0 group by 名字
select 名字,count(数量) as 日 from 表1 where datediff(dd,A.STARTTIME,getdate())=0 group by 名字
或者将上面结果合并成
名字 月 周 日
张三 100 50 10
李四 90 49 12