How can I compare value from previous records?
Table:
ID SAMPLEDATE LEVEL PASSED
1 1/1/2016 0 1
2 1/2/2016 1 1
3 1/3/2016 2 0
4 1/4/2016 1 1
5 1/5/2016 2 0
Is the last record (ordered by SAMPLEDATE
) the same LEVEL
as the last record that failed? If yes, return TRUE otherwise return FALSE.
So in my example data the last record that failed with LEVEL
2. Then the last record (before the 1/5/2016 record) that failed on 1/3/2016 was the same LEVEL, so TRUE would be returned. If it was a different LEVEL FALSE would be returned.