I would like to have a query for below scenario. I have a table with event and occurence time as below:
EventName OccuredAtDatetime
EventA 2019-07-03 00:14:01
EventA 2019-07-03 01:14:01
EventA 2019-07-03 01:34:01
EventB 2019-07-03 01:13:03
I would like to know whether a event has occured within a time interval (30 minutes in this example) , say starttime as 2019-07-03 00:00:00 and endtime as 2019-07-03 02:00:00, the interval would be like
IntervalName StartTime EndTime
Interval1 2019-07-03 00:00:00 2019-07-03 00:30:00
Interval2 2019-07-03 00:30:00 2019-07-03 01:00:00
Interval3 2019-07-03 01:00:00 2019-07-03 01:30:00
Interval4 2019-07-03 01:30:00 2019-07-03 02:00:00
So, the output would be like,
EventName Interval1 Interval2 Interval3 Interval4
EventA Yes No Yes Yes
EventB No No Yes No
This is also my first post on stackoverflow so please let me know if the data are not in the preferred format or if there any additional questions. Thanks!