I use mysql 5.1.
This is my DB schema :
id user_id type created_at
1 32 X 2012-11-19
2 32 Y 2012-11-18
3 30 X 2012-11-16
4 32 Z 2012-11-17
5 31 Y 2012-11-13
6 32 Z 2012-11-9
I want that my SQL query returns the user_id
, type
, and the lastest created_at
for each type.
I tried to make this request:
SELECT max(type) FROM notification WHERE user_id=34 ORDER BY type
but it returns only the latest created_at
.