write a query to find 4th max salary
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
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 |
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 |
what are the features and advantages of object-oriented programming? : Sql dba
How to create a table using constraints... IF i change the PARENT KEY value ,then CHILD KEY table will also to change in the another table... plz reply ur answers @ mak2786@gmail.com Arunkumar
Which is better stored procedure or query?
explain what is mysql? : Sql dba
What is sqlite format?
What is the difference between microsoft access and sql server?
how instead of triger is helpful for mutating tables errors handlling ?
What is use of term?
Is sql low level language?
What are the topics in pl sql?
How can the performance of a trigger be improved?
What are variables in pl sql?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)