List:General Discussion« Previous MessageNext Message »
From:Daniel Brown Date:March 4 2008 4:09pm
Subject:Re: Getting the last item in a "group by" query?
View as plain text  
On Tue, Mar 4, 2008 at 10:57 AM, Esbach, Brandon
<Esbachb@stripped> 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 t.serial_number ORDER
BY t.date DESC LIMIT 0,1;

    That will give only the latest date.


-- 
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
Thread
Getting the last item in a "group by" query?Brandon Esbach4 Mar
  • Re: Getting the last item in a "group by" query?Daniel Brown4 Mar
  • Re: Getting the last item in a "group by" query?Baron Schwartz4 Mar
Re: Getting the last item in a "group by" query?Daniel Brown4 Mar
  • RE: Getting the last item in a "group by" query?Brandon Esbach4 Mar
    • Re: Getting the last item in a "group by" query?Daniel Brown4 Mar