How to find 2nd highest salary simple way in sql server | Find 2nd highest salary in a minute

preview_player
Показать описание

#codenargs #sqlquestion
Please Share, Like and Subscribe for more videos.

Finding Nth highest salary in a table is the most common question asked in interviews. I have displayed two ways..
1. Using sub Query
Query:
Select top 1 Salary From
(Select distinct top 3 Salary From Employee order by Salary desc) emp
order by Salary

2. using dense_rank() function.
Query:
Select Id, Name, Salary From
(Select Id, Name, Salary, DENSE_RANK() Over (Order By Salary Desc) salary_rank From Employee) Emp
Where salary_rank=2

sql tutorial for beginners,
sql interview questions and answers
sql tutorial
sql for beginners
sql course
sql server
sql queries interview questions and answers
what is sql
sql basics for beginners
Рекомендации по теме