Reputation: 614
Please, help to find appropriate query.
Task: table contains sms. Select latest sms from each conversation
Table example:
Query result
Thanks a lot in advance
Upvotes: 0
Views: 46
Reputation: 3656
Here is the solution to your problem:
SELECT MAX(id) AS ID, conversationId, Max(date) AS Date
FROM Table_name
GROUP BY conversationId
Upvotes: 2
Reputation: 50163
Use subquery with correlation
select *
from table t
where date = (select max(date) from table where conversationid = t.conversationid)
Upvotes: 1