Skip to content
Advertisement

How to get the time difference of first occurrence of a record with another record

We have a monitoring system that posts data to our postgres database in this format:

Our goal is to calculate the time between wa-event-triggered events and wa-event-recovered events, if i have data that looks like this, my query below works just fine.

This gives me this table which is great!

However the data is not always sequential in that our alerting system can post multiple wa-event-triggered events before we finally have a wa-event-recovered event, so how would i get the time difference between the first wa-event-triggered found and the first wa-event-recovered found and ignore all the wa-event-triggered events in between given that there will be hundreds of these triggered/recovered pairs.

Advertisement

Answer

You can just include the changed records and use your method:

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