I'm having a SQL issue.
Basically, I have a list of actions stored in a table called ACTIONS. These can happen to objects which have a unique ID. There can be several actions per object
What I need to do is select all the objects whose most recent action has the column status on 2.
The Data looks something like this :
OBJECT DATE STATUS
------ ------------------- ------
OBJ1 13/11/2017 16:45:55 1
OBJ1 12/11/2017 15:45:55 2
OBJ2 13/11/2017 06:42:55 2
OBJ2 12/11/2017 16:45:55 1
And the output would be : OBJ2
The query looks something like this :
SELECT ID_OBJECT
FROM ACTIONS
WHERE LASTACTIONSTATUS = 2
I initially tried a sub-query selecting the status of the last action, but my issue is that I can't pass the value of my Object to the sub-query.
Tried fooling around with group by and order by but because there are several objects in the table I can't get all the objects needed
Does anybody have an idea as to how I could go about doing this ?
Thanks!