How to group by date and not datetime in oracle?

by darrion.kuhn , in category: MySQL , 2 months ago

How to group by date and not datetime in oracle?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by jasen_gottlieb , 2 months ago

@darrion.kuhn 

To group by date and not datetime in Oracle, you can use the TRUNC() function to remove the time component of a datetime column. Here's an example query:

1
2
3
SELECT TRUNC(some_date_column) AS date_only, COUNT(*)
FROM your_table
GROUP BY TRUNC(some_date_column);


In this query, replace some_date_column with the column containing the datetime values you want to group by. The TRUNC() function is used to remove the time component of the datetime values, so that the grouping is done based on the date only.