Hi guys, may I have your attention and help on this. Thanks!
The table "message(id, userId, content, createdTime)". now I need to find out those records of the latest message (namely the max createdTime) for each user, the returned results should be ordered by createdTime.
e.g
data in the table:
1 'eric' 'hello' '2009-12-30'
2 'lisa' 'yes' '2010-01-21'
3 'eric' 'thanks' '2009-10-06'
4 'lisa' 'hey' '2010-09-12'
I got one: select msg. * from (select m.* from message as m order by m.createdTime) as msg group by msg.userId order by msg.createdTime DESC. but I think it's not good due to low performance.
the expected results:
4 'lisa' 'hey' '2010-09-12'
1 'eric' 'hello' '2009-12-30'