find out the second highest salary?
Answers were Sorted based on User's Feedback
Answer / mallikarjun
select max(sal) from emp
where sal < select max (sal)from emp
Mallikarjun
| Is This Answer Correct ? | 216 Yes | 86 No |
Answer / ananth
this is for 2nd highest sal in sql server database
select * from emp where sal=(select max(sal) from emp where
sal<(select max(sal) from emp))
| Is This Answer Correct ? | 119 Yes | 13 No |
Answer / v.karthikeyan
select * from emp
where &n-1=(select count(distinct(sal)) from emp b
where emp.sal<b.sal)
| Is This Answer Correct ? | 62 Yes | 30 No |
Answer / hiten
select max(sal) from emp where sal not in(select max(sal)
from emp);
| Is This Answer Correct ? | 25 Yes | 2 No |
Answer / prasant
SQL> select max(sal) from emp where sal<(select max(sal)
from emp);
MAX(SAL)
----------
3000
| Is This Answer Correct ? | 22 Yes | 3 No |
Answer / abhijit ramakant parb
select min(a.sal) from(select distinct d.sal from emp d
order by sal desc) a where rownum<=2;
To retrieve all columns
select * from emp where sal=(select min(a.sal) from(select
distinct d.sal from emp d order by sal desc) a where
rownum<=2);
| Is This Answer Correct ? | 12 Yes | 6 No |
Answer / karthikeyan
select max(sal) from emp
where sal <(select max (sal)from emp);
| Is This Answer Correct ? | 7 Yes | 1 No |
Answer / premsagar12
select max(sal) from emp where sal<(select max(sal) from emp);
| Is This Answer Correct ? | 7 Yes | 1 No |
Answer / peter
SQL> select max(sal) sal
2 from (select sal,
3 dense_rank() over
4 (order by sal desc) rnk
5 from emp )
6 where rnk = 2;
SAL
----------
3000
SQL>
| Is This Answer Correct ? | 14 Yes | 9 No |
Answer / janmejaya
select top(1) * from employee where salary in (select
distinct top(2) salary from employee order by salary desc)
order by Salary
Above query is dynamic, if u want 3rd highest then just
change 2 to 3 , Please Try It
| Is This Answer Correct ? | 4 Yes | 0 No |
How to create an initialization parameter file?
why you need store procedure ? where do we use it in a Java project? can you get the code for as store procedure using in Java?
I have created one package with out procedures in package specification and in package body i have used 2 procedures. is it compile????
How to sort the query output in oracle?
I have table-A(1,2,3)& table-B(3,4,5).what is the different b/w below questions? A union all B? B union all A?
What is memory advisor in Oracle?
Can we create more than one constraint to column ?
what r tyhe major differences between oracle 9i & 10g?
Is postgres faster than oracle?
Define oracle database
What is a Synonym ?
The join defined by the default data link is an outer join yes or no ?