how to find the fifth highest salary?
Answers were Sorted based on User's Feedback
Assuming that EMP table with Sal column
SELECT MIN(sal) FROM
(SELECT DISTINCT sal FROM emp WHERE
ROWNUM < 6
ORDER BY sal DESC )
- If fifth highest then ROWNUM < 6
- If n'th highest then ROWNUM < n+1
Regards
J
| Is This Answer Correct ? | 11 Yes | 5 No |
Answer / soumen saha
select max(sal) from table where level=5 connect by prior
sal>sal;
| Is This Answer Correct ? | 5 Yes | 2 No |
Answer / saraswathi muthuraman
SQL> select * from emp_test order by sal desc;
1003 20010 11
1001 10000 11
1001 10000 11
1002 100 11
1004 99 11
1005 50 11
1006 25 11
SQL> select * from (select emp_no,dep_no,sal,rank() over
(order by sal desc) as rank_list from emp_test) where
rank_list =5;
1004 11 99 5
| Is This Answer Correct ? | 5 Yes | 5 No |
Answer / saraswathi muthuraman
Try this :
SQL> select * from (select emp_no,dep_no,sal,rank() over
(order by sal desc) as rank_list from emp_test group by
emp_no,dep_no,sal) where rank_list =5;
1005 11 50 5
This seems to be a correct answer if few employ having same sal
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / nagireddy karri
select min(emp_sal) from (select (Emp_sal) from(select
Emp_sal from emp order by emp_sal desc) and rownum<=5)
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / arun
Select max(Employee_Sal) From Employee where Employee_Code
in(Select Top 5 Employee_Code,Employee_Name,Employee_Sal
From Employee Order by Employee_sal desc)
| Is This Answer Correct ? | 1 Yes | 3 No |
Does storing of data in stored procedures increase the access time? Explain?
What do you mean by Correlated subquery?
What is the difference between a user defined function and a stored procedure?
What is RDBMS KERNEL?
What do you mean by flat file database?
What is an Entity type?
What is the Disadvantage in File Processing System?
What is the difference between stored procedures and stored functions in oracle?
Are the resulting relations of PRODUCT and JOIN operation the same?
can we use transformer in datastage without any input link?
Define the "integrity rules"?
What are external procedures ? Why and when they are used?
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)