I have a Table with a \"Date\" Column. I want to group by hour for a specific date.
Alternatively, I would have suggested EXTRACT (datetime), but (empahsis mine):
If HOUR, MINUTE, or SECOND is requested, then expr must evaluate to an expression of data type TIMESTAMP, TIMESTAMP WITH TIME ZONE, TIMESTAMP WITH LOCAL TIME ZONE, or INTERVAL DAY TO SECOND. DATE is not valid here, because Oracle Database treats it as ANSI DATE data type, which has no time fields.
Therefore, the result is a little bit ugly:
SELECT EXTRACT (HOUR FROM CAST (m.a_date AS TIMESTAMP)) AS hour_,
COUNT (*) AS count_
FROM MY_TABLE m
GROUP BY EXTRACT (HOUR FROM CAST (m.a_date AS TIMESTAMP));