Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Rownum Between (SOLVED)

542539Oct 2 2007 — edited Oct 2 2007

Why do I get these seemingly peculiar results when I change the rownum criteria?

SQL> with data as
  2  ( select 'a' result from dual union
  3    select 'b' result from dual union
  4    select 'c' result from dual union
  5    select 'd' result from dual union
  6    select 'e' result from dual union
  7    select 'f' result from dual union
  8    select 'g' result from dual )
  9  select result from
 10  ( select result from data order by result )
 11  where rownum between 1 and 4;
a
b
c
d

Elapsed: 00:00:00.00
SQL> with data as
  2  ( select 'a' result from dual union
  3    select 'b' result from dual union
  4    select 'c' result from dual union
  5    select 'd' result from dual union
  6    select 'e' result from dual union
  7    select 'f' result from dual union
  8    select 'g' result from dual )
  9  select result from
 10  ( select result from data order by result )
 11  where rownum between 2 and 4;

no rows selected

Elapsed: 00:00:00.00
SQL>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 30 2007
Added on Oct 2 2007
6 comments
28,309 views