orale 查询每年、每月、每日统计量的sql语句
2017-05-21 21:12
274 查看
每年
select to_char(createtime, 'YYYY') 年, count(*) from table group by to_char(createtime, 'YYYY');
每季度
select to_char(createtime, 'q') 年, count(*) from table group by to_char(createtime, 'q');
每月
select to_char(createtime, 'YYYY') 年, to_char(createtime, 'mm') 月, count(*) from table group by to_char(createtime, 'YYYY'), to_char(createtime, 'mm');
每日
select to_char(createtime, 'YYYY') 年,to_char(createtime, 'mm') 月,to_char(createtime, 'dd') 日, count(*) from table group by to_char(createtime, 'YYYY'), to_char(createtime, 'mm'),to_char(createtime, 'dd');
当中createtime为date类型。假设为varchar先要转换为date类型
select to_char(createtime, 'YYYY') 年, count(*) from table group by to_char(createtime, 'YYYY');
每季度
select to_char(createtime, 'q') 年, count(*) from table group by to_char(createtime, 'q');
每月
select to_char(createtime, 'YYYY') 年, to_char(createtime, 'mm') 月, count(*) from table group by to_char(createtime, 'YYYY'), to_char(createtime, 'mm');
每日
select to_char(createtime, 'YYYY') 年,to_char(createtime, 'mm') 月,to_char(createtime, 'dd') 日, count(*) from table group by to_char(createtime, 'YYYY'), to_char(createtime, 'mm'),to_char(createtime, 'dd');
当中createtime为date类型。假设为varchar先要转换为date类型
相关文章推荐
- orale 查询每年、每月、每日统计量的sql语句
- orale 查询每年、每月、每日统计量的sql语句
- SQL语句统计每小时,每天、每月、每年的_数据
- SQL语句统计每天、每月、每年的 数据
- SQL语句统计每天、每月、每年的数据
- SQL语句统计每天、每月、每年的数据
- SQL语句统计每天、每月、每年的 数据
- SQL语句统计每天、每月、每年的数据
- SQL语句统计每天、每月、每年的 数据
- 数据库专题——SQL语句统计每天、每月、每年的数据
- Sql 每月,每日,每年统计
- SQL语句统计每天、每月、每年的数据
- SQL语句统计每天、每月、每年的 数据
- 分享[ASP.NET] SQL语句统计每天、每月、每年的数据 编辑:吴立星
- 收集SQL语句统计每天、每月、每年的数据
- SQL语句统计每天、每月、每年的 数据
- 分享[ASP.NET]SQL语句统计每天、每月、每年的数据 作者:吴立星
- sq更新语句条件子查询中有分组统计的sql,导致错误1093
- 每日学习心得:SQL查询表的行列转换/小计/统计(with rollup,with cube,pivot解析)
- oracle 按每天,每周,每月,每季度,每年查询统计数据