Select the Nth lowest value from a table?
Submitted by: Administratorselect 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 level
select max(sal)"nth min sal" from(select distinct sal from emp order by sal) where rownum<=&N
Submitted by: Administrator
'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 level
select max(sal)"nth min sal" from(select distinct sal from emp order by sal) where rownum<=&N
Submitted by: Administrator
Read Online Oracle SQL Job Interview Questions And Answers
Top Oracle SQL Questions
☺ | Explain Difference between an implicit and an explicit cursor? |
☺ | Explain What is difference between SUBSTR and INSTR? |
☺ | Explain What are various joins used while writing SUBQUERIES? |
☺ | Explain Difference between procedure and function.? |
☺ | Explain What is an UTL_FILE.What are different procedures and functions associated with it? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Forms Reports Interview Questions. |