//按自然周统计
select to_char(date,'iw'),sum()
from
where
group by to_char(date,'iw')
//按自然月统计
select to_char(date,'mm'),sum()
from
where
group by to_char(date,'mm')
//按季统计
select to_char(date,'q'),sum()
from
where
group by to_char(date,'q')
//按年统计
select to_char(date,'yyyy'),sum()
from
where
group by to_char(date,'yyyy')
SQL 按周,月,季度,年查询统计数据
最新推荐文章于 2024-07-07 03:42:39 发布
本文介绍如何使用SQL按不同时间周期(自然周、自然月、季度和年度)进行数据汇总的方法。通过具体SQL语句示例,帮助读者掌握针对日期字段进行分组统计的技术要点。
1243

被折叠的 条评论
为什么被折叠?



