Select the Nth lowest value from a table?
Answers were Sorted based on User's Feedback
Answer / mahesh
select *from(select ename,sal,row_number()over(order by sal desc) rk from emp) where rk=2;
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / nishi
select level, min('col_name') from my_table where level = '&n' connect by prior
('col_name') <'col_name') group by level;
Example:
Given a table called emp with the following columns:
-- id number
-- name varchar2(20)
-- sal number
--
-- For the second lowest salary:
-- select level, min(sal) from emp
-- where level=2
-- connect by prior sal < sal
-- group by lev
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / venkat
select * from emp minus select * from emp where rownum <= (select count(*) - &n from emp);
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / basanti
select * from(select rownum,ename from employee order by rownum desc) where rownum<=5;
| Is This Answer Correct ? | 0 Yes | 0 No |
From the database level, how can you tell under which time zone a database is operating?
what is difference between foreign key and reference key
How to export data to a csv file?
How to pass a cursor variable to a procedure?
What do you mean by merge in oracle?
What happens to the current transaction if a ddl statement is executed?
What is an Index ?
3. Adapt your query in (2) above so that only post codes with more than twenty orders are displayed.
How to create lov dynamically at runtime & attach to text field?
What is the difference between truncate & delete command?
Which Department has MOST NUMBER of employees?
8 Answers IBM, LeadSquared, Mastek,
How to sort the query output in oracle?