There is a query I need to write that will filter out multiples of the same downtime event. These records get created at the exact same time with multiple different timestealrs which I don't need. Also, in the event of multiple timestealers for a downtime event I need to make the timestealer 'NULL' instead.
Example table:
Id | TimeStealer | Start | End | Is_Downtime | Downtime_Event |
---|---|---|---|---|---|
1 | Machine 1 | 2022-01-01 01:00:00 | 2022-01-01 01:01:00 | 1 | Malfunction |
2 | Machine 2 | 2022-01-01 01:00:00 | 2022-01-01 01:01:00 | 1 | Malfunction |
3 | NULL | 2022-01-01 00:01:00 | 2022-01-01 00:59:59 | 0 | Operating |
What I need the query to return:
Id | TimeStealer | Start | End | Is_Downtime | Downtime_Event |
---|---|---|---|---|---|
1 | NULL | 2022-01-01 01:00:00 | 2022-01-01 01:01:00 | 1 | Malfunction |
2 | NULL | 2022-01-01 00:01:00 | 2022-01-01 00:59:59 | 0 | Operating |