Getting the last item in a group by query?

2008-03-04 Thread Esbach, Brandon
There is likely a blindingly obvious solution to this, I need to do a group by expression in my query and get the latest row based on a date field in the same table. Is this even possible, and any tips on how to do that? Example of data and query: --- Table: =(pseudo table based on

Re: Getting the last item in a group by query?

2008-03-04 Thread Daniel Brown
On Tue, Mar 4, 2008 at 10:57 AM, Esbach, Brandon [EMAIL PROTECTED] wrote: [snip!] SELECT t.pass, t.id FROM theTable t GROUP BY t.serial_number ORDER BY t.date desc Try adding the LIMIT keyword. SELECT t.pass, t.id FROM theTable t GROUP BY

Re: Getting the last item in a group by query?

2008-03-04 Thread Daniel Brown
On Tue, Mar 4, 2008 at 11:24 AM, Esbach, Brandon [EMAIL PROTECTED] wrote: Thanks for the reply, Sorry, should have been more specific on that :). I need to access the last record by date for each serial_number in the table (not just latest record) Okay, this is untested, so I don't

RE: Getting the last item in a group by query?

2008-03-04 Thread Esbach, Brandon
Hmm didn't notice that replies are sent to personal emails :o! I'll look down that avenue once I've completed the mysql version upgrade (mysql 4 on my test bench, mysql5 upgrade in progress on the production server) Thanks again! -Original Message- From: Daniel Brown [mailto:[EMAIL

Re: Getting the last item in a group by query?

2008-03-04 Thread Daniel Brown
On Tue, Mar 4, 2008 at 12:02 PM, Esbach, Brandon [EMAIL PROTECTED] wrote: Hmm didn't notice that replies are sent to personal emails :o! I'll look down that avenue once I've completed the mysql version upgrade (mysql 4 on my test bench, mysql5 upgrade in progress on the production server)

Re: Getting the last item in a group by query?

2008-03-04 Thread Baron Schwartz
Hi, On Tue, Mar 4, 2008 at 10:57 AM, Esbach, Brandon [EMAIL PROTECTED] wrote: There is likely a blindingly obvious solution to this, I need to do a group by expression in my query and get the latest row based on a date field in the same table. Is this even possible, and any tips on how