每年 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類型