select lastest 2 element group by a topic_id
- by Luca Romagnoli
Hi i have to select the 2 lastest element for every topic
ex:
table: msg
id | topic_id
-----------
1 | 1
2 | 1
3 | 1
4 | 1
5 | 2
6 | 2
7 | 2
8 | 3
i want obtain these rows:
3 1
4 1
6 2
7 2
8 3
How can i do?
thanks