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
Can we rollback truncate?
What is the use of sql trace?
How do I enable sql encryption?
Define select, insert, create, delete, update, drop keywords
What is t sql in sql server?
How do I remove all records from a table?
What is mutating error?
Explain the difference between sql and mysql.
What is a field in a database?
What are commit, rollback, and savepoint?
How do I find duplicates in sql?
what is sql in mysql? : Sql dba
how to include numeric values in sql statements? : Sql dba
What are the types of index in sql?
What is sql key?