sql统计 统计每个月的 合并成一条数据

2025-05-18 14:58:15
推荐回答(1个)
回答1:

每天
select count(1),to_char(StartTime,'yyyy-mm-dd') from tablename where UrlTarget like '%Agent%' and to_char(StartTime,'yyyy-mm-dd') >='2010-05-01' group by to_char(StartTime,'yyyy-mm-dd') order by to_char(StartTime,'yyyy-mm-dd') ;
每月
select count(1),to_char(StartTime,'mm') from tablename where UrlTarget like '%Agent%' and to_char(StartTime,'yyyy-mm-dd') >='2010-05-01' group by to_char(StartTime,'mm') order by to_char(StartTime,'mm') ;