So I have a log table. Rows are basically like this:
id function
n init()
n+1 check()
n+2 done()
... repeat
But there are problems when it's like this:
id function
n init()
n+1 check()
n+2 done()
n+3 check() <-- should be init!
n+4 done()
How do I find rows that happen only in init->check->done->check->done contagious order? Basically after row done() it must be check() again in order to be SELECTed.
Is there a way to do this in 1 (or minimal) query? Performance is not an issue.