find out the third highest salary?
Answers were Sorted based on User's Feedback
Answer / mihir nasikkar
Here n is 3
SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP n salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / karunakar varma
select a,sal from (select dense_rank() over (order by sal
desc) a,sal from emp) where a=3
| Is This Answer Correct ? | 4 Yes | 2 No |
Answer / abbas
SELECT * FROM
(
SELECT EMPLOYEECODE, SAL, Rank() OVER (ORDER BY SAL DESC )
RANKNEW FROM EMPLOYEE)
WHERE RANKNEW = 3
| Is This Answer Correct ? | 9 Yes | 8 No |
Answer / mahesh
select * from emp where sal<(select max(sal) from emp
where sal<(select max(sal) from emp))
| Is This Answer Correct ? | 11 Yes | 10 No |
Answer / nirad
select Top 1 *
from ( select top 3 * from Customer order by salary desc )
tempt
order by salary asc
if you want third lowest just desc with asc and asc with
desc and even if you want 2 or other hight value just
change inner query value of 3
| Is This Answer Correct ? | 3 Yes | 2 No |
Answer / chinmaya
Select Top 1 Sal from (Select Top 3 Sal from emporder by
Sal desc) x order by Sal
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / vanaja
select * from emp5 where salary in(select min(salary) from
emp5 where salary in(select top 3 salary from emp5 order by
salary desc))
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / ajit
SQL QUERIES FOR FINDING Nth HIGHEST SALARY
SELECT DISTINCT (a.salary) FROM EMPLOYEES A WHERE &N = (SELECT COUNT (DISTINCT (b.salary)) FROM EMPLOYEES B WHERE a.salary<=b.salary);
| Is This Answer Correct ? | 1 Yes | 0 No |
How to define an anonymous procedure with variables?
What are the various oracle database objects?
can anyone help me ? an index has been done on the primary key of a table. an update operation was performed on that table. now my question is 1> what abt the performance ? means faster or slower due to indexing ? 2> does the operation affect to the primary key constraint ?
I have one table :EID,Depid,ename,sal I want to have max(sal) in each department.
5 Answers Microsoft, Oracle, TCS,
What is BBED in Oracle?
How to recover a dropped table in oracle?
What is partitioned table in Oracle?
Two triggers one is before insert and other is after insert are firing on a table.If 10 times you insert in a table.Then how many times before trigger and how many types after trigger will fire in pl/sql.
What are a query and state the different types of queries and their uses?
What is a static data dictionary in oracle?
What is a Sequence ?
What is an oracle recycle bin?