I have this table:
ID|Item-FK |timestamp|status
=============================
1 | 123 | ... | OK
2 | 123 | ... | FAILED
...
I want to query get all items which last status was FAILED
.
If an item failed yesterday, and is OK today, I don't want to see it.
Best Answer
Use Partition by to get last record where Status is failed.
EDIT: you can use EXISTS instead on IN