How to group by one column but select last value
This is my database for messages
I want to group by receiver_id and this is my SQL
SELECT * FROM messages WHERE sender_id=2
ORDER BY created_at DESC
GROUP BY receiver_id
HAVING COUNT(receiver_id)>=1
It's working but it always shows subject "Bok" and created_at=2013-08-19
20:49:22 I would like to show latest created_at and subject, in this
example 2013-08-20 14:29:41
This is my output
No comments:
Post a Comment