how to find the second highest salary from emp table?
Answer Posted / ashish damohiya
Answer :
Select max(salary) from Emp_Table where max(salary) not in
(Select max(Salary) from Emp_Table)
this sufficient answer.
but there change the format of question that
How to find the second highest salary of each employee form
emp table ?
Answer :
with cte as (
select rank() over(order by emp_name) rank1 , ROW_NUMBER()
OVER(partition by emp_name ORDER BY basic desc) row,
emp_name, basic from emp_master)
select * from cte where row =2 or rank1 in ( select rank1
from cte group by rank1 having count(rank1)=1)
there i am used the MS SQL Server 2005.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the use of primary key?
How many joins in sql?
What is the meaning of disabling a trigger?
What is cost in sql execution plan?
What is sap sql anywhere?
What does rownum mean in sql?
Is merge a dml statement?
What is numeric function sql?
What is tuple in sql?
How do I view a view in sql?
What are inner outer left and right joins in sql?
Why do we use view in sql?
what are the non-standard sql commands supported by 'mysql'? : Sql dba
Which command is used to delete a trigger?
what are the difference between clustered and a non-clustered index? : Sql dba