oracle 按每天、周、月、季度、年统计

//按天统计,createtime为数据库的date类型,格式为:yyyy-MM-dd hh24:mi:ss
select trunc(createtime,'DD') as 日期,count(主键) as 数量 from tablename 
group by trunc(createtime, 'DD') order by trunc(createtime, 'DD') 
e.g. 
select trunc(bjsj,'DD') as 日期,count(jjdbh) as 数量 from t_jjd 
 where bjsj>=to_date('2017-05-01 00:00:00','yyyy-MM-dd hh24:mi:ss') 
 and bjsj

 

你可能感兴趣的:(database,database,oracle)