I have SQL which outputs rows of a date time stamp and a status change flag (0 or 1)
I need to get the timespan from the first record, where the flag will be 0, to when the status flag changes to 1, ignore records when the flag is still at 1, then get the time span after it changes back to 0 till the last record. The status change flag may flip between 0 and 1 any number of times.
So i need to be able to compare the status change flag to the previous row, and decide whether I need to keep accumulating the difference in the date time stamps.
I have been looking into writing a cursor but keep reading about how cursors are horribly inefficient.
Hopes this make any sense.