sql query for selecting conditionally
Posted on 2014-04-07
I've been staring at this for too long and I can't get my head wrapped around this.
To simplify this, let's say I have a table that holds computer name, status, timestamp. For example:
computer1 | ERROR | 4/7/2014 4:21 PM
computer1 | OK | 4/7/2014 4:22 PM
computer2 | OK | 4/7/2014 4:22 PM
computer2 | ERROR | 4/7/2014 4:23 PM
From this I want a list of computer that have a current status of ERROR. If that computer has a more recent record with a status of OK then I don't want to see it.