Re: [GENERAL] How do I write this query? Distinct, Group By, Order By?

2010-10-06 Thread Min Yin
wrote: On Tue, Oct 5, 2010 at 9:26 PM, Min Yin wrote: Hi There, I have a table looks like this: (order_id, user_id, order_time) One user_id can have multiple orders with order_id as the primary key, now I want to get a list of users, ordered by their latest order respectively, for example, if

Re: [GENERAL] How do I write this query? Distinct, Group By, Order By?

2010-10-06 Thread Min Yin
up by users.id order by max(orders.order_time) desc; If all I can get is a list of user_id, then can I get the list of user records in ONE 2nd query? Thanks! On 10/5/2010 8:45 PM, Josh Kupershmidt wrote: On Tue, Oct 5, 2010 at 10:26 PM, Min Yin wrote: Hi There, I have a table looks like

[GENERAL] How do I write this query? Distinct, Group By, Order By?

2010-10-05 Thread Min Yin
Hi There, I have a table looks like this: (order_id, user_id, order_time) One user_id can have multiple orders with order_id as the primary key, now I want to get a list of users, ordered by their latest order respectively, for example, if user A has two orders, one on today, the other a mo