orale 查询每年、每月、每日统计量的sql语句

每年
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语句,布布扣,bubuko.com

orale 查询每年、每月、每日统计量的sql语句

上一篇:在Intellij IDEA (2016.3.5版)中快捷显示Servlet和Jsp文档


下一篇:“DBUtility.DbHelperSQL”的类型初始值设定项引发异常 “DBUtility.DbHelperSQL”的类型初始值设定项引发异常