SELECT to_char( "日期字段" , 'YYYY-MM-dd' ) time , count ( * ) FROM "表名" GROUP BY time ;
SELECT to_char( "日期字段" , 'YYYY-MM' ) time , count ( * ) FROM "表名" GROUP BY time ;
SELECT to_char( "日期字段" , 'YYYY' ) time , count ( * ) FROM "表名" GROUP BY time ;
统计周几产生多少数据(day:标识星期几的英文全称 比如 :wednesday(周三),dy:标识星期几的简称 比如:wed(周三))
SELECT to_char( "日期字段" , 'day' ) time , count ( * ) FROM "表名" GROUP BY time ;
SELECT CASE WHEN to_char( "create_time" , 'dy' ) = 'sun' THEN '周日' WHEN to_char( "create_time" , 'dy' ) = 'mon' THEN '周一' WHEN to_char( "create_time" , 'dy' ) = 'tue' THEN '周二' WHEN to_char( "create_time" , 'dy' ) = 'wed' THEN '周三' WHEN to_char( "create_time" , 'dy' ) = 'thu' THEN '周四' WHEN to_char( "create_time" , 'dy' ) = 'fri' THEN '周五' WHEN to_char( "create_time" , 'dy' ) = 'sat' THEN '周六' END as time , count ( * )
FROM "table"
GROUP BY time
SELECT to_char( "日期字段" , 'Q' ) time , count ( * ) , to_char( "日期字段" , 'YYYY' ) ctime FROM "表名" GROUP BY time , ctime;
统计每月第几天产生多少数据(和日期统计差不多,3个DDD统计当前年的第多少天)
SELECT to_char( "日期字段" , 'DD' ) time , count ( * ) , to_char( "日期字段" , 'YYYY-MM-dd' ) ctime FROM "表名" GROUP BY time , ctime;
SELECT to_char( "日期字段" , 'YYYY/MM/DD:PM:DY' ) time , count ( * ) FROM "表名" GROUP BY time ;
SELECT TO_CHAR( "日期字段" , 'YYYY/MM/DD' ) AS NOW, TO_CHAR( "日期字段" - INTERVAL '7' day , 'YYYY/MM/DD' ) AS PAST, count ( * ) FROM "表名" GROUP BY NOW, PAST;
SELECT TO_CHAR( "日期字段" , 'YYYY/MM/DD HH24:MI:SS' ) AS NOW, TO_CHAR( "日期字段" - INTERVAL '7' second , 'YYYY/MM/DD HH24:MI:SS' ) AS PAST FROM "表名"
SELECT TO_CHAR( "日期字段" , 'YYYY/MM/DD HH24:MI:SS' ) AS NOW, TO_CHAR( "日期字段" - INTERVAL '7' minute , 'YYYY/MM/DD HH24:MI:SS' ) AS PAST FROM "表名"
SELECT TO_CHAR( "日期字段" , 'YYYY/MM/DD HH24:MI:SS' ) AS NOW, TO_CHAR( "日期字段" - INTERVAL '7' hour , 'YYYY/MM/DD HH24:MI:SS' ) AS PAST FROM "表名"
SELECT TO_CHAR( "日期字段" , 'YYYY/MM/DD HH24:MI:SS' ) AS NOW, TO_CHAR( "日期字段" - INTERVAL '7' day , 'YYYY/MM/DD HH24:MI:SS' ) AS PAST FROM "表名"
SELECT TO_CHAR( "日期字段" , 'YYYY/MM/DD HH24:MI:SS' ) AS NOW, TO_CHAR( "日期字段" - INTERVAL '7' month , 'YYYY/MM/DD HH24:MI:SS' ) AS PAST FROM "表名"
SELECT TO_CHAR( "日期字段" , 'YYYY/MM/DD HH24:MI:SS' ) AS NOW, TO_CHAR( "日期字段" - INTERVAL '7' year , 'YYYY/MM/DD HH24:MI:SS' ) AS PAST FROM "表名"
SELECT TO_CHAR( "日期字段" , 'YYYY/MM/DD HH24:MI:SS' ) AS NOW, TO_CHAR( "日期字段" - 8 * INTERVAL '7' hour , 'YYYY/MM/DD HH24:MI:SS' ) AS PAST FROM "表名"