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

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 > serv

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

2008-03-04 Thread Esbach, Brandon
[mailto:[EMAIL PROTECTED] Sent: 04 March 2008 16:56 To: Esbach, Brandon; MySQL User Group Subject: Re: Getting the last item in a "group by" query? On Tue, Mar 4, 2008 at 11:24 AM, Esbach, Brandon <[EMAIL PROTECTED]> wrote: > Thanks for the reply, > > Sorry, should have bee

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 do

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 GROU