Re: [sqlite] Finding max of each group?

2005-08-12 Thread Colin Fleming
Thanks for the advice, guys. After fiddling around with it a bit, I went for the age-old solution of changing the data and the requirements so it wasn't necessary :) Thanks, Colin On 10/08/05, Kurt Welgehausen <[EMAIL PROTECTED]> wrote: > > select conversation_id, count(*), max(unread),

Re: [sqlite] Finding max of each group?

2005-08-10 Thread Kurt Welgehausen
> select conversation_id, count(*), max(unread), max(updated_on) > from messages > where conversation_id in () > group by conversation_id; > > 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? Assuming that the

Re: [sqlite] Finding max of each group?

2005-08-10 Thread Austin Ziegler
On 8/10/05, Colin Fleming <[EMAIL PROTECTED]> wrote: > 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

[sqlite] Finding max of each group?

2005-08-10 Thread Colin Fleming
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