how to check the 3rd max salary from an employee table?
Answers were Sorted based on User's Feedback
Answer / akula
select min(sal) from(select distinct(sal) from emp order by sal desc) where rownum<=3;
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / dulal
Without Using MAX or MIN keyword
select TOP 1 EmpName, RevisedMinutes
from tblEncounter
where RevisedMinutes IN(select distinct Top 3
RevisedMinutes from tblEncounter order by RevisedMinutes
desc)
order by RevisedMinutes asc
Is This Answer Correct ? | 2 Yes | 2 No |
Answer / srinivas
select max(sal) from emp where sal<(select max(sal) from emp where sal<(select max(sal) from emp))
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / kotesh
select level,max(salary) from employee
where level=3
connect by prior salary>salary
group by level;
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / pavan ranga
select top 1 (salary),Name from customers
where salary not in (Select top 2 (Salary) from customers)
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / a.brahmam
select * from(select rownum r,sal from(select * from table name order by sal desc))
where r=3;
(or)
select * from(select rownum,sal from table name order by sal desc)
where rownum<=3
minus
select * from(select rownum,sal from table name order by sal desc)
where rownum<=2
(or)
select * from(select sal,dense_rank()over(order by sal desc)r from table name)
where r=3
Is This Answer Correct ? | 0 Yes | 0 No |
SELECT *
FROM(
SELECT SALARY, DEPARTMENT_ID,EMPLOYEE_ID, DENSE_RANK() OVER (PARTITION BY DEPARTMENT_ID ORDER BY SALARY DESC) AS RN
FROM EMPLOYEES
)
WHERE RN = 2
;
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / neeraj
SELECT TOP 1 * FROM [SELECT TOP 3 * FROM Emp_Salary
ORDER BY Salary DESC;]
ORDER BY Salary;
Is This Answer Correct ? | 3 Yes | 4 No |
Answer / akilis.org@hotmail.com
Let us Assume
Table Name=salary
Column Name=maxsal
select * from salary order by maxsal desc limit 2,1;
Enjoy the simple code :)
Is This Answer Correct ? | 1 Yes | 2 No |
Answer / kumar sumit
select max(sal) from emp where sal not in(select max(sal)
from emp where sal not in(select max(sal) from emp))
Is This Answer Correct ? | 0 Yes | 3 No |
what are the system privileges that are required by a schema owner (user) to create a trigger on a table?
what is the difference between clustered and non clustered index in sql? : Sql dba
what is the forward decleration in packages?
What is difference between table and view?
table :- city name country code abc 11 bcd 22 cde 232 def 33 write a procedure , so that when we give a phone no. eg - 1123456789 - o/p sud be city name = abc if phone no. - 2322345897 , o/p sud be =cde note - bcd and cde city name sud be diff. as dey diff only with th last no. Pls ans. this questnion.
What is tuple in sql?
How do I view tables in sql developer?
what are %TYPE and %ROWTYPE? what is the difference?
7 Answers ICICI, Saama Tech, Sail,
What is Pragma EXECPTION_INIT ? Explain the usage ?
why not null constraint showing its constraint type as 'c'
What is difference between left and right outer join?
What is sql mysql pl sql oracle?