write a query to find 4th max salary

Answers were Sorted based on User's Feedback



write a query to find 4th max salary..

Answer / raj

for example if we take emp table:

select a.sal from emp a where 4=(select count(distinct(b.sal)) from emp b where a.sal<=b.sal);

Is This Answer Correct ?    3 Yes 1 No

write a query to find 4th max salary..

Answer / debashis mohanty

Select Name,Deptno,Salary,Rank from
(
Select Ename Name,Deptno,Sal Salary,Rank () over(Order By Sal Desc) Rank from emp
)
Where Rank=4

Is This Answer Correct ?    2 Yes 0 No

write a query to find 4th max salary..

Answer / nishi.swain@gmail.com

select distinct sal from table_name t1 where 4=(select count(distinct sal) from table_name t2 where
t1.sal<=t2.sal);

Is This Answer Correct ?    0 Yes 0 No

write a query to find 4th max salary..

Answer / raj

for example if we take emp table, the query like this...
select a.sal from emp a where 4=(select count(distinct(b.sal))from emp b where a.sal<=b.sal)

Is This Answer Correct ?    0 Yes 0 No

write a query to find 4th max salary..

Answer / sreeharibabu

SELECT id
FROM (select salary2.*, rownum rnum from
(select * from test ORDER BY id DESC) salary2
where rownum <=4)
WHERE rnum >= 4;

Is This Answer Correct ?    0 Yes 0 No

write a query to find 4th max salary..

Answer / mujahid

Simple one is i think:
Select min(sal) from (select sal from emp order by sal desc LIMIT 4);

Is This Answer Correct ?    0 Yes 0 No

write a query to find 4th max salary..

Answer / anand v

select user_name,sal,rank over(order by sal desc) rank from table
where rank =4

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More SQL PLSQL Interview Questions

Can you do multiple joins in sql?

0 Answers  


What is a clob in sql?

0 Answers  


What does bitemporal mean?

0 Answers  


What is bulk collections?

2 Answers  


How does a self join work?

0 Answers  






what is the difference between a local and a global temporary table? : Sql dba

0 Answers  


Is natural join same as inner join?

0 Answers  


what is the correct way of selection statement a. select/from/table_name/orderby/groupby/having b. select/from/table_name/groupby/having/orderby

5 Answers   HCL, JPMorgan Chase,


Is mariadb a nosql database?

0 Answers  


What is plpgsql language?

0 Answers  


How to retrieve Duplicate Rows only in a Table? Suppose if a Table Name is "Education". It consists of multiple columns. Then if we insert rows into this table with duplicate records then how can we retrieve only duplicate records from that table?

28 Answers   Alps, Aricent, Bank Of America, Wipro,


In a package if we have 10 procedures or functions,How to know which will execute first?

1 Answers   Sollet Soft,


Categories