I have for example these 2 tables:
Organiser Events
---------- -------
id 1 id
|__ * organiser_id
date
status
How do I select the ids of all organisers who’s latest event it’s status equals for example ‘active’.
I think I have to use max(date) in maybe a subquery or do I need to use a join? Still haven’t found the solution, so any help is appreciated!
Thanks
EDIT:
I just found this solution (dunno if this is the best one?):
SELECT o.id, e.date
FROM Organiser o
INNER JOIN events e on e.organiser_id = o.id
WHERE e.date = (SELECT max(date)
FROM events e2
WHERE e2.organiser_id = o.id)
1 Answer