0

select * from (select * from (select emp_salary from employee order by emp_salary) where rownum<6 order by emp_salary)where rownum =6;

in above query rownum is not working , if i will run below query then rownum is working, i am confussed about it please help

select * from (select * from (select emp_salary from employee order by emp_salary) where rownum<6 order by emp_salary)where rownum =1;

select * from (select * from (select emp_salary from employee order by emp_salary) where rownum<6 order by emp_salary)where rownum =1;

  • 2
    Rownum is the row ordinal for every row returned to the consumer. It cannot skip value 1 by definition – astentx Jul 04 '23 at 17:01

1 Answers1

0

Can you try with:

  select * 
   from (
         select rownum as num_row, x.* 
           from (
                 select emp_salary 
                   from employee 
                  order by emp_salary
                ) x
          where rownum <= 6 
          order by emp_salary
        ) 
  where num_row = 6;

Thanks.

Massi FD
  • 360
  • 4
  • 8