How to group by date and not datetime in oracle?

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

How to group by date and not datetime in oracle?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by jasen_gottlieb , 4 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.

Related Threads:

How to group datetime into intervals of 3 hours in mysql?
How to group and count record by date using laravel?
How to query from multiple tables and group them by date in laravel?
How to convert date string to date in oracle?
How to compare date to format date on oracle?
How to use oracle group by?