find the third highest salary?
Answers were Sorted based on User's Feedback
Answer / anu
select *
FROM (select emp1.* ,rownum rnum
from ( select * from emp order by sal_amount desc ) emp1
where rownum<=3)
where rnum >=3
| Is This Answer Correct ? | 1 Yes | 0 No |
select vu.sal from
(select DENSE_RANK() over(order by sal desc) as sr,
sal from emp) vu
where vu.sr=3
| Is This Answer Correct ? | 3 Yes | 3 No |
Answer / meher
SELECT SAL FROM EMP A WHERE &N= (SELECT COUNT(DISTINCT) SAL
FROM EMP B WHERE A.SAL<B.SAL)
--Pass the value for N as 2 to get 3rd highest salary.
--pass 0 for highest sal,1 for 2nd highest,2 for 3rd
highest and so on....
| Is This Answer Correct ? | 6 Yes | 6 No |
Answer / pradeep
select * from emp where sal in(select min(sal) from (select
sal from emp order by sal
desc) where rownum <= 3);
| Is This Answer Correct ? | 3 Yes | 3 No |
Answer / gautam
select * from (
SELECT ROWNUM as RANK, ename, sal
FROM (SELECT ename,sal FROM emp ORDER BY sal DESC)
WHERE ROWNUM <= 3)
where rank=3
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / deepak kumar
SELECT sal FROM empORDER BY sal DESC LIMIT 2 , 1
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / mousumi dalai
select min(sal) from emp where sal in
( select sal from
(select sal from emp order by sal desc)
where rownum<=3)
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / anil pednekar
select * from (select sal from table1 group by sal ) where
row num=3
| Is This Answer Correct ? | 1 Yes | 2 No |
Answer / satish prajapati
select min(sal) from (select
sal from emp order by sal
desc) where rownum <= 3
| Is This Answer Correct ? | 2 Yes | 4 No |
what are the different types of joins?
Why do we use triggers?
explain access control lists. : Sql dba
What is ttitle and btitle?
What is record data type?
Why stored procedures are faster than query?
Why we use joins in sql?
Do you understand the meaning of exception handling?
if table named a is there and 4 records are there then how to swap (1 and 3) and (2 and 4) records at a time
What is trigger explain with example?
What is bind reference and how can it be created?
What is intersect?
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)