how to find the second highest salary from emp table?
Answers were Sorted based on User's Feedback
select top 1 salary from emp where salary in
(select top 2 salary from emp order by salary desc)
order by salary
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / kiran
select max(sal) from emp where sal in(select sal from emp
where sal<>(select max(sal) from emp))
/
Is This Answer Correct ? | 1 Yes | 0 No |
select max(emp-sal) from emp
where emp-sal <(select max(emp-sal) from emp).
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / anurag kumar rai
select max(sal) from employee where sal<(select max(sal) from employee)
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / sachin verma
select sal from emp
where rownum=2
order sal by Desc
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / anil maurya
select top 1 rate from HumanResources.EmployeePayHistory
where rate<(select MAX(rate) as R from HumanResources.EmployeePayHistory)
order by rAte Desc
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / surendra sharma
select min(sal) from table_name where sal in
(SELECT top 2 sal FROM table_name order by sal desc)
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / yash goyal
Select Distinct salary
from employees e
where &no-1=(select count(distinct salary )
from employees
where E.salary < salary);
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / bharat g
select * from (select ename,sal,dense_rank() over (order by sal desc) ranking from emp) where ranking=2;
Is This Answer Correct ? | 1 Yes | 0 No |
What is acid property in a database?
How well can multiple sessions access the same data simultaneously ?
how to find the second highest salary from emp table?
211 Answers CIS, Cognizant, Cosmosoft, DAS, EDS, GreenTech, HOV Services, IBM, Infosys, National Institute of Science and Technology, Patni, Persistent, Polaris, TCS, Wipro, Yardi, Zensar,
What are the datatypes a available in PL/SQL ?
What is t sql used for?
what is the differnce between procedure and function? in both dml operations can work and in procedure through out parameter you can return value ,then what is the differce?
What is the diff between Truncate table / delete <table name> purge
What are the types of views in sql?
does sql support programming? : Sql dba
Delete duplicate records in the emp table.
Types of cursor locks and explanation each of them ?
How do you add a column to a table?