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
Why is sql important?
Why is sharding used?
Can dml statements be used in pl/sql?
What is pl sql architecture?
Why do we use joins?
How to change a value of the field ‘salary’ as 7500 for an employee_name ‘john’ in a table employee_details?
Explain what is rdbms?
What is mutating trigger?
What does stand for in sql?
Explain some predefined exceptions.
What are all the different normalization?
How many joins can you have in sql?
Is sql dba a good career? : SQL DBA
What is a primary key example?
Is sql pronounced sequel or sql?