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: group by, order by and rownum

Re: group by, order by and rownum

From: Ed Prochak <edprochak_at_magicinterface.com>
Date: Thu, 15 Aug 2002 16:07:26 GMT
Message-ID: <3D5BFE6C.1E510DC@magicinterface.com>

Brian Murphy wrote:
>
> >ops$clbeck_at_ORA8I.WORLD> select value
> > 2 from ( select value,
> > 3 row_number() over ( partition by pid order by id ) r
> > 4 from foo )
> > 5 where r = 2
> > 6 /
> >
> >VALUE
> >----------
> >B
> >D
>
> That's exactly what I was looking for. Partition by. I never would have
> thought of that one. I don't know enough about oracle.
>
> brian
>
> ps. I wish this was a homework assignment.

Everytime this issue comes up. I wonder why? I have NEVER encountered requirements where the first "n" results rows were not needed (in your case n=1).

Just to satisfy my curiosity, Why would you need the second row and not the first? Given that this is a real world case I'm doubly curious.

Enquiring minds want to know, please.

-- 
Edward J. Prochak   --- Magic Interface, Ltd.
Ofc: 440-498-3700
on the web at       --- http://www.magicinterface.com
email: ed.prochak_at_magicinterface.com
Received on Thu Aug 15 2002 - 11:07:26 CDT

Original text of this message

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