Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: rownum question
ptsao_at_sequeltech.com wrote:
>
> Hi,
>
> I was able to do
>
> select * from table where rownum = 1;
> select * from table where rownum <= 20;
> update table
> set id = rownum;
>
> but, I CAN NOT do
>
> select * from table where rownum = 2;
> select * from table where rownum = 3;
> ...
>
> Can someone tell me why?
>
> Thanks,
>
> Phil Tsao
It's kind of like your age - you can't be 2 unless you were 1 previously. Rownum is incremented as rows are returned from the query. Since the first row is always rownum 1 but your where clause excludes that row from the return set, you can never get to rownum 2. The only valid way to use rownum is =1 or <N. Anything else will not return any rows.
-- --- Allen Kirby AT&T ITS Production Services akirby_at_att.com Alpharetta, GA.Received on Thu Jan 30 1997 - 00:00:00 CST