Correlated subquery

Display the 5th lowest sal from emp table using Correlated subquery

Questions by lalit.eng.kumar

Showing Answers 1 - 24 of 24 Answers

SQL> select x.* from (
  2  select last_name, salary, rank() over(order by salary desc) as high_salary
  3  from employee)x where x.high_salary = 5;

LAST_NAME      SALARY HIGH_SALARY
---------- ---------- -----------
Martin        1234.56           5

SQL> select x.* from (
  2  select last_name,salary, row_number() over(order by salary desc) as num
  3  from employee)x where x.num = 5;

LAST_NAME      SALARY        NUM
---------- ---------- ----------
Martin        1234.56          5

  Was this answer useful?  Yes

display the 5th lowest sal from emp table using Correlated subquery

table have data:
----------------

SQL> select last_name,salary from employee order by salary asc;

LAST_NAME      SALARY
---------- ----------
Cat           1232.78
Martin        1234.56
Black         2334.78
Rice          2344.78
Smith         6544.78
Mathews       6661.78

6 rows selected.

SQL>

select x.* from (
select last_name, salary, rank() over(order by salary asc) as high_salary
from employee)x where x.high_salary = 5;

LAST_NAME      SALARY HIGH_SALARY
---------- ---------- -----------
Martin        1234.56           5

select x.* from (
select last_name,salary, row_number() over(order by salary asc) as num
from employee)x where x.num = 5;

LAST_NAME      SALARY        NUM
---------- ---------- ----------
Martin        1234.56          5

  Was this answer useful?  Yes

sampra

  • Mar 6th, 2012
 

select * from Hello h where 5=(select count (distinct amt) from hello where h.amt>amt)

This will give the 5th record from lowest

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions