group by time oracle sql
/* DANIEL MOMBEYNI */
SELECT M.YYYYMMDD,
M.HH24,
M.HALF_PART,
FROM (SELECT TO_CHAR(T.TIME_FIELD,
'yyyy/mm/dd') AS "YYYYMMDD",
TO_CHAR(T.TIMESTAMP, 'HH24') AS "HH24",
CASE
WHEN TO_CHAR(T.TIME_FIELD, 'MI') BETWEEN 0 AND 30 THEN
'0-30 min'
WHEN TO_CHAR(T.TIME_FIELD, 'MI') BETWEEN 31 AND 59 THEN
'31-59 min'
END AS "HALF_PART"
FROM TBL_NAME T) M
GROUP BY M.YYYYMMDD, M.HH24, M.HALF_PART
ORDER BY 1