How to group by date in Oracle database

I keep forgetting how to do this.

How to group on a date column (date_col in the example) in Oracle:

SELECT COUNT(*) FROM TABLE GROUP ON TO_CHAR(date_col, 'DD-MON-YYYY HH:MI:SS')

For other format strings than

'DD-MON-YYYY HH:MI:SS'

see this page.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.