I\'m working on a small project in which I\'ll need to select a record from a temporary table based on the actual row number of the record.
How can I select a record
There are 3 ways of doing this.
Suppose u have an employee table with the columns as emp_id
, emp_name
, salary
. You need the top 10 employees who has highest salary.
Using row_number()
analytic function
Select * from
( select emp_id,emp_name,row_number() over (order by salary desc) rank
from employee)
where rank<=10
Using rank()
analytic function
Select * from
( select emp_id,emp_name,rank() over (order by salary desc) rank
from employee)
where rank<=10
Using rownum
select * from
(select * from employee order by salary desc)
where rownum<=10;