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

Where do you edit cognos sql in report studio?

3 Answers   HCL,


What is the difference between set functions and filter function in dimensional data?

0 Answers  


I have to apply drill through 1,2,7 out of 10 in order method, how can i do?

1 Answers   Satyam, TCS,


..Architectural difference between cognos reportnet and cognos8?

3 Answers  


Hi All, Is there any way to check whether a value is selected in a Multi-select tree prompt? I have a tree prompt and want to get to know whetehr which values user has selected,i want to so that values on the top of the report. I Have used that paramDisplayValue('paramername'),But it will display only last selected value. For Example i have tree prompt with one level Region- >country->states If user select region Asia it will dislay the all the Countries in that region and then if user select India it will display the states related to india only Suppose Hierachy look like this: Asia->India->Andhra Pradesh. I want to show this hierachy on the top of the report How it is possible? Can you please help me?

0 Answers   IBM,






What condition do we use in Cognos when multiple path exits to reach the fact table.(i.e in BOXI we use CONTEXT when multiple path exit)

0 Answers  


What is conditional Formatting?

2 Answers   HCL,


what is mean by cognos powerhouse?

1 Answers   TCS,


What are products of cognos?

0 Answers  


Can u please describe the different types of traps with eg. Thanks

2 Answers  


What is the metric store database?

0 Answers  


what is the role of cognos comsultant?what actually it means?pls reply

0 Answers  


Categories