Write a SQL query which should fetch the 5th maximum salary
of an employee from the table?
Answers were Sorted based on User's Feedback
Answer / vsandhyana
Hi Hashmatulla Baig,
I think your query will not give the desired output. it
should be modify please refer below for the same.
SELECT empno, sal
FROM
(
select empno, sal, (ROW_number() OVER (order by sal desc)) R
from emp
order by sal desc
)
WHERE R = 5;
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / balanandam
select * from emp where sal =(select sal from(select sal,rank() over(order by sal desc) sal_rank from emp group by sal) where sal_rank=&rank)
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / dramesh511
select sal from emp e where 5=(select count(sal) from
emp e1 where e.sal<=e1.sal)
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / hashmatulla baig
SELECT empno, sal
FROM
(
select empno, sal, ROW_number() OVER (order by sal desc) R
from emp
order by sal desc
)
WHERE R = 5;
| Is This Answer Correct ? | 3 Yes | 2 No |
Answer / karthik murugeshan
SELECT B.Salary FROM (SELECT Salary FROM EMP)A,(SELECT
Salary FROM EMP)B
WHERE A.Salary>=B.Salary
GROUP BY B.Salary
HAVING COUNT(B.Salary)=5
| Is This Answer Correct ? | 3 Yes | 3 No |
Answer / balanandam
select * from((select * from emp order by sal desc where rownum<=5)MINUS(select * from emp order by sal desc where rownum<=4))
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / dhanu
SELECT DISTINCT SAL FROM EMP E WHERE 5>=(SELECT COUNT(DISTINCT SAL) FROM EMP A WHERE A.SAL<=E.SAL)ORDER BY SAL DESC
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / sreenivasa
SELECT DEPTNO, ENAME, SAL FROM EMP A WHERE 4 = (SELECT COUNT
(B.SAL) FROM EMP B WHERE A.SAL < B.SAL)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / pradeep nagireddy
select *
from(select rownum r,sal from emp order by sal desc)
where rownum = 5;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / srcreddy
select* from
(select rownum rank,ename,sal from emp order by sal desc) where rank=5;
| Is This Answer Correct ? | 0 Yes | 0 No |
Can you define report item?
Hi Friends, Just want to know, day to day is increasing or decreasing Cognos Usage in the Market? New Reporting tools to driving Reporting Market Spotfire, Tableau,Qlick View, some other New Tools. Which Reporting tool can generate Lot of Opportinities in the Market? Please Reply to this, My Advanced Thank to you. Thank You Kumar
How applying "Level Span" in Cognos 8.3?
using of matric studio we can developed to scorecard ... what is the meaning by scorecords
It is possible with out same Queries(both Reports) we can build the drilltrough between them? and how?
Interval Prompt's Usage? Example for usage in Project
how can you set the image in the report
What are the types of security?
Hi Buddies... i want to appear for cognos BI-Author certification. can anyone of you send me cognos latest dump. please help me.. cognoslalitha@gmail.com
wt is the OLAP Scrubbing in Framework manger & use? How can we developed a query items by using alredy existing query items?
1.how do nyou configure link between fwm and database (source).if you created fwm where it will be? and if you create reports where it is stored? 2.what is spic shot in fwm?
how u migrate the reports from impromptu to reportnet???