rdmueller
rdmueller

Reputation: 11022

SQL: Group by "business days"

I would like to group a search result by days, but unfortunately, the definition is not a day from midnight to midnight (00:00-24:00), but from 06:00 to 06:00.

Any easy solution? If possible in PL-SQL

Upvotes: 4

Views: 238

Answers (1)

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174309

It should be as simple as this:

GROUP BY TRUNC(DATE - 6/24)

- 6/24 subtracts 6 hours from the datetime in the column DATE and thus all times between 06:00 and 06:00 will be the same day. TRUNC then removes the time part as you only need the date.

Upvotes: 8

Related Questions