Select o.* from (
Select max(updated_at) as maxdate, sender_user_id, recipient_user_id
from chattable
group by sender_user_id, recipient_user_id
) as t
join chattable as o on t.sender_user_id=o.sender_user_id and t.recipient_user_id=o.recipient_user_id and t.maxdate=o.upadet_at