There is a 5000 EMP in company.how we find out the 5th
highest getting salary employee outof 5000 employes........
Answers were Sorted based on User's Feedback
Answer / nagireddy
select max(sal) from emp a where 5=(select count(distinct sal)
from emp b where a.sal<=b.sal);
| Is This Answer Correct ? | 13 Yes | 3 No |
Answer / kasyapa
select * from emp A where 4 = (select count(*) from emp B
where A.sal<B.sal)
| Is This Answer Correct ? | 6 Yes | 2 No |
Answer / satish kalynm
SELECT * FROM T999 WHERE SAL<(SELECT MAX(SAL) FROM T999
WHERE SAL<(SELECT MAX(SAL) FROM T999 WHERE SAL<(SELECT
MAX(SAL) FROM T999 WHERE SAL<(SELECT MAX(SAL) FROM T999))));
| Is This Answer Correct ? | 5 Yes | 2 No |
Answer / rajib
select max(salary) from staff where salary not in(select
salary from staff order by salary desc fetch first 4 rows
only)
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / payel
SELECT * FROM STAFF AA
WHERE 5 = (SELECT COUNT (SALARY) FROM STAFF WHERE SALARY
<= AA.SALARY );
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / ashok
in above answers what is a.sal and b.sal please explain me
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / sachin
SELECT MAX(SALARY) FROM EMP WHERE SALARY <
(SELECT MAX(SALARY) FROM EMP WHERE SALARY <
(SELECT MAX(SALARY) FROM EMP WHERE SALARY <
(SELECT MAX(SALARY) FROM EMP WHERE SALARY <
(SELECT MAX(SALARY) FROM EMP WHERE SALARY ))))
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / pavan
try this one....
select * from emp where emp_Id = (select emp_Id from emp
order by sal)
and count(*) < 6;
| Is This Answer Correct ? | 0 Yes | 5 No |
Answer / udhay
SELECT MAX(salary)
FROM employees
WHERE salary
NOT IN (SELECT TOP 4 salary FROM employees ORDER BY salary
DESC)
| Is This Answer Correct ? | 1 Yes | 7 No |
What is page size in db2?
What does the CHECK Utility do ?
My sql statement select avg(salary) from emp yields inaccurate results. Why?
What is a Foreign Key?
0 Answers Tavant Technologies, Zensar,
What is meant by union and union all?
How to insert more than one record using insert?
How to find last record before record through SQLRPGLE?
How to run db2 command in windows?
can i code union in cobol-db2 pgm ?
What is the connection string to connect to the DB2 Database ?
What is a DB2 bind?
What is the difference between group by and order by?