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

i am having a table having name cust_employee.i use this table in my model after i published that to cognos connection .i generate some reports. after that in my data base cust_employee table is changed to cust_emp.how can i get this table into my report.i again import and published means its time consuming,in simple how can get the changed table in to my model pls pls ans me....

2 Answers  


wat is called Model dimension?

0 Answers   IBM,


1.tyes of security in cognos?.how to use rank function? 2.what is content store? 3.what is content manager? 4.how 2 use rank function?

3 Answers  


what is the security module used in cognos?

2 Answers   Cognos, IBM,


How to create model and how to test model?

0 Answers  






What's the limitation of 'Page Footer' in Report Studio? e.g. If I have an activity prompt (list of activities in a Search & Select Prompt) and selected around 2500 activites from the 'Activity' Search & Select Prompt and when I ran the report I got a message "#! Overflow" in page footer. Can somebody please tell me what's max. limit. I tried with around 300 activities and page footer displayed the activities. Your help will be appriciated.

0 Answers   DELL,


What is loop in frameworkmanager ?

4 Answers  


Can any one give the example for slicing and dicing of data ?(with simple query)

3 Answers   Cognos,


How do you schedule process automatically in cognos.I.e we have 50 reports and 100 users that will schedule daily, weekly, and monthly basis? Pls, give the answers the query early on.

3 Answers  


What are the components of the report studio?

0 Answers  


How to give a securites in object level&datalevel&pakege lavel in frame work manager?

1 Answers  


Define query studio?

0 Answers  


Categories