I am having some issues figuring out how to generate the SQL script to do the following. (Refer to screenshot below)
I basically have a bunch of values which go into a bad state, then into a good state, then bad, then good etc. over a given time period
For a given timestamp when a value goes into a bad state (i.e. where CONDITION field says "ALARM"), I need to find the next consecutive timestamp where it goes good (CONDITION field says "ALARM OK") and then generate a list for any situations where the time difference between the two is greater than 12 hours.
Can anyone provide some advice or direction? I was thinking maybe take a given record timestamp for an alarm, then filter through all the other ones for "alarm OK' and then subtract the timestamps to find the smallest one, but not sure....
Image is at i55.tinypic.com/21o57h2.jpg
(I can't post full link cos I'm a new member so obviously you need the http in front)
I basically have a bunch of values which go into a bad state, then into a good state, then bad, then good etc. over a given time period
For a given timestamp when a value goes into a bad state (i.e. where CONDITION field says "ALARM"), I need to find the next consecutive timestamp where it goes good (CONDITION field says "ALARM OK") and then generate a list for any situations where the time difference between the two is greater than 12 hours.
Can anyone provide some advice or direction? I was thinking maybe take a given record timestamp for an alarm, then filter through all the other ones for "alarm OK' and then subtract the timestamps to find the smallest one, but not sure....
Image is at i55.tinypic.com/21o57h2.jpg
(I can't post full link cos I'm a new member so obviously you need the http in front)