颗粒化查询统计sql

SELECT
 TO_CHAR (to_date(substr(PAY_TIME,12,2), 'hh24'),'hh24') || ':' || LPAD (
  FLOOR (TO_CHAR(TO_DATE(SUBSTR(PAY_TIME,15,2),'mi'), 'mi') / 5) * 5,
  2,
  0
 ) cjsj,
 COUNT (*) num
FROM
 PAY_ORDER_INFO
GROUP BY
 TO_CHAR (to_date(substr(PAY_TIME,12,2), 'hh24'),'hh24') || ':' || LPAD (
  FLOOR (TO_CHAR(TO_DATE(SUBSTR(PAY_TIME,15,2),'mi'), 'mi') / 5) * 5,
  2,
  0
 )
ORDER BY
 TO_CHAR (to_date(substr(PAY_TIME,12,2), 'hh24'),'hh24') || ':' || LPAD (
  FLOOR (TO_CHAR(TO_DATE(SUBSTR(PAY_TIME,15,2),'mi'), 'mi') / 5) * 5,
  2,
  0
 );

  

posted @ 2020-09-18 14:58  mandy3651423  阅读(136)  评论(0编辑  收藏  举报