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

1. what is the exact use of hint in sql. 2. How we can avoid index scan in sql even though index is there in the table.

1 Answers   Polaris,


What is synonyms?

0 Answers  


What is a schema? How is it useful in sql servers?

0 Answers  


ex: take one schema in that t1,t2,.....tn tables and you don't no the table name also. write a procedure if enter columns name then display the maching columns .otherwise display the unmatch columns.

1 Answers   Zensar,


in procedure how to return a value

3 Answers   Wipro,






What is NOCOPY?

6 Answers   DELL,


What is record data type?

0 Answers  


Differentiate pl/sql and sql?

0 Answers  


What is ON DELETE CASCADE?

3 Answers  


How many database objects (trigger, packages, sequence etc) uses a particular field in a given table. For ex: I want to know how many database object uses the ATTRIBUTE1 in the PO_VENDORS table. What query will give me the result showing the database object name(package, trigger etc), field_name used (in this case ATTRIBUTE1) and table_name (in this case PO_VENDORS).

2 Answers   IBM,


What is a subquery in sql?

0 Answers  


Can we update views in sql?

0 Answers  


Categories