I'm writing a messaging system, and I have the following problem. I
have a conversations table, and a messages table that has a foreign
key to conversations. I can do something like the following to provide
a summary:

select conversation_id, count(*), max(unread), max(updated_on)
from messages
where conversation_id in (<list of ids>)
group by conversation_id;

(code may contain typos, sorry, haven't got my code right here).

I use max(updated_on) to get the date of the most recent message in
the conversation. Is there a way to return the ID of this message?

Thanks for any help,
Colin

Reply via email to