oracle查询每隔5分钟区间内的数据量
SELECT COUNT (DISTINCT tmp.PLATE) totalNum, tmp.newTime FROM ( SELECT T .LICENSE_PLATE plate, TO_CHAR ( T .create_time, 'yyyymmddhh24mi' ) oldTime, -- 原来的时间 CASE WHEN SUBSTR ( TO_CHAR (T .create_time, 'mi'), 2, 1 ) < 5 THEN TO_CHAR ( T .create_time, 'yyyymmddhh24' ) || SUBSTR ( TO_CHAR (T .create_time, 'mi'), 1, 1 ) || 0 ELSE TO_CHAR ( T .create_time, 'yyyymmddhh24' ) || SUBSTR ( TO_CHAR (T .create_time, 'mi'), 1, 1 ) || 5 END AS newTime -- 时间段伪列 FROM B_TRACK T WHERE T .create_time >= TO_DATE ( '20180703000000', 'yyyymmddhh24miss' ) ORDER BY T .create_time ASC ) tmp GROUP BY tmp.newTime ORDER BY tmp.newTime DESC