I have a table that looks like this
id, from_user_id, to_user_id, date
1, 1, 2, 2019-09-19 17:19:18
2, 1, 2, 2019-09-19 17:19:36
3, 6, 2, 2019-09-19 17:28:33
I want every row where to_user_id = 2
but I want from_user_id to be distinct
and it needs to be order by date desc
This is what im hoping for:
id, from_user_id, to_user_id, date
2, 1, 2, 2019-09-19 17:19:36
3, 6, 2, 2019-09-19 17:28:33
Is there a simple/clean solution without joins?
I’ve tried group by and subqueries, but cant get it right.