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

What is a join?

0 Answers  


What is a merge query?

1 Answers  


How does sql developer connect to oracle database?

0 Answers  


i hv 30 rows with date.ex:1month hav 4 weeks i want 1st day of the every week.write the qry for that.example jan has 4 weeks i need 1st dd for evry wk

1 Answers   Aspire,


What type of database is sql?

0 Answers  






Can we use SQL%ISOPEN in implicit cursors? Does this attribute works properly in Implicit Curosors?

3 Answers  


what are the limitations of identity column? : Transact sql

0 Answers  


How we get all_group_function's(Sum,avg,count,max and min_value of a column(Sal) Using pl/sql anonymous block, with out using group function's. You shouldn't use more than one select statement in entire the program. Like cursor c is select * from <table_name>; except this you can't use another select statement. You can use no of variables as per requirement.

1 Answers  


is it mandatory to select all the column in a view then what columns should be selected

2 Answers  


How to get the procedure's, function's name from a package if it is wrapped(both spec & body).

2 Answers  


Is pl sql still used?

0 Answers  


Give an example of Full Outer Join?

1 Answers   IBM,


Categories