SQL - Grouping results by custom 24 hour period SQL - Grouping results by custom 24 hour period oracle oracle

SQL - Grouping results by custom 24 hour period


group by trunc(your_date - 1/4)


Days are whole numbers in oracle so 6 am will be 0.25 of a dayso :

select trunc(date + 0.25) as period, count(*) as numberfrom tablegroup by trunc(date + 0.25 )

I havent got an oracle to try it on at the moment.


Well, you could group by a calculated date.So, add 6 hours to the dates and group by that which would then technically group your dates correctly and produce the correct results.