请教大家一个问题: SQL中根据时间分组统计常见的有:
按日,按周,按月,按季统计
按日统计可以采用: convert(char(10),getdate(),121)
按周统计可以采用: datepart(wk,getdate())
按月统计可以采用: convert(char(7),getdate(),121)
那请问按季度统计该怎么样写呢?
按日,按周,按月,按季统计
按日统计可以采用: convert(char(10),getdate(),121)
按周统计可以采用: datepart(wk,getdate())
按月统计可以采用: convert(char(7),getdate(),121)
那请问按季度统计该怎么样写呢?
group by datepart(year,getdate()) , datepart(quarter,getdate())
-----------
4(所影响的行数为 1 行)