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



Write a SQL query which should fetch the 5th maximum salary of an employee from the table?..

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

Write a SQL query which should fetch the 5th maximum salary of an employee from the table?..

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

Write a SQL query which should fetch the 5th maximum salary of an employee from the table?..

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

Write a SQL query which should fetch the 5th maximum salary of an employee from the table?..

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

Write a SQL query which should fetch the 5th maximum salary of an employee from the table?..

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

Write a SQL query which should fetch the 5th maximum salary of an employee from the table?..

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

Write a SQL query which should fetch the 5th maximum salary of an employee from the table?..

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

Write a SQL query which should fetch the 5th maximum salary of an employee from the table?..

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

Write a SQL query which should fetch the 5th maximum salary of an employee from the table?..

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

Write a SQL query which should fetch the 5th maximum salary of an employee from the table?..

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

Post New Answer

More Cognos Interview Questions

Can you define materialized view?

0 Answers  


What do you mean by drill through report?

0 Answers  


How security is concerned with Reportnet? Explain its implementing steps.

0 Answers   iFlex,


What is the difference between Open Connection command ang Open Session Command?

0 Answers  


3.User1 doveloped some report,user2 modify the same report and user 3 also updates in that same report? how to identify that report will be modified or not?

1 Answers   IBM, Thomson Reuters,






what is the procedure for scheduling conditional rendering?

0 Answers   Syntel,


I have Date,product,Quantity_Sold columns and I want Product, MTD(month Till date),YTD(Year Till Date) as output. Can anyone help me with the logic in getting MTD i.e quantity sold from 1st of this month to till date (i.e. 01- 11-2013 to 26-11-2013) and YTD i.e QTD sold from 1st date of the year to till date(i.e. 01-01-2013 to 26-11-2013). Sample output model: Product MTD YTD

1 Answers   L&T,


Are you aware of any limitations in Cognos?

1 Answers   HCL,


----------------What is Scopr Relationship?

1 Answers  


After installation of Cognos Reportnet how do i know how much of entire Cognos server is being utilised at any instatnt of time?

1 Answers  


what is view? types of views?

3 Answers   HCL,


what are determinants?

4 Answers   College School Exams Tests, IBM,


Categories