Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: getting multiple Newest records

Re: getting multiple Newest records

From: jb <jbecker_at_fhcrc.org.righteo>
Date: Tue, 28 Jan 2003 15:37:13 -0800
Message-ID: <3E371429.8050005@fhcrc.org.righteo>

Steve Wicklund wrote:

>Hello all;
>
> Given a table where there are columns id (varchar), description
>(varchar), and date (date), where none of the columns are unique; I am
>trying to select the 'newest' row (as determined by date col) of each
>id. <<snip>>
>
>rowId id description date
>_______________________________
>row1 01 yada 01-10
>row2 02 yada2 01-10
>row3 01 newYada 01-12
>row4 02 yada3 01-20
>row5 03 yadayada 02-20
>row5 04 yada5 02-01
>
><<snip>>
>

SQL> select myid, descrip, d_event
  2 from yada
  3 where (myid, d_event) in
  4 (select myid, max(d_event) from yada group by myid);

     MYID DESCRIP                                  D_EVENT
--------- ---------------------------------------- ----------
        1 quit                                     01/21/2003
        2 ordered                                  01/12/2003
        3 registered                               01/16/2003


someone has a faster way i'm open to that.

cheers
jrb Received on Tue Jan 28 2003 - 17:37:13 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US