Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: group by, order by and rownum
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.comReceived on Thu Aug 15 2002 - 11:07:26 CDT
![]() |
![]() |