Skip to content
Advertisement

Oracle SQL – count number of active/open tickets per hour by day

I have a dataset from oracle db that looks something like this:

I need to calculate the number of active tickets in an hour time slot. So if the ticket was opened before that hour, and closed after the hour it would be counted. All days and hours need to be represented regardless if there are active tickets open during that time. The expected output is:

Any help would be greatly appreciated.

Advertisement

Answer

You need a calendar table. In the query below it is created on the fly

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement