Here’s the table:
id - date - attempts
--------------------------------------------
1 - 2012-12-11 14:52:06.143 - success
2 - 2012-12-11 15:51:52.320 - whatever
3 - 2012-12-11 12:51:52.321 - success
4 - 2012-12-11 12:51:52.312 - whatever
5 - 2012-12-11 14:51:52.320 - fail
I am trying to get the latest ‘fail’ and the latest ‘success’ rows and then, of the two, see if the latest one was a failure (there can be success rows later than fail rows).
I can’t just select the latest row, as it might be other than ‘success’ or ‘fail’.
The inner query will identify the record with the latest date where the attempt is either success or failure, the outer query combines with the results of inner query to identify failure records.