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: DA Morgan <damorgan_at_exesolutions.com>
Date: Tue, 28 Jan 2003 16:09:04 -0800
Message-ID: <3E371BA0.C7ABAB22@exesolutions.com>


jb wrote:

> 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

Depending on the data ... EXISTS might be faster then again it might not be.

Daniel Morgan Received on Tue Jan 28 2003 - 18:09:04 CST

Original text of this message

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