Query to find Nth Highest/Minimum Salary in SQL | SQL Interview Question | LIMIT Keyword in SQL

preview_player
Показать описание
Query to find Nth Highest/Minimum Salary in SQL
SQL Interview Question
LIMIT Keyword in SQL

Select Max(Salary) from Employee;
To get the second highest salary use a sub query along with Max() function as shown below.
Select Max(Salary) from Employees where Salary (please add less than sign) (Select Max(Salary) from Employees);
To get Nth Highest Salary

Select Salary from Employee Order By Salary DESC LIMIT n-1,1;

To get Nth Minimum Salary
Select Salary from Employee Order By Salary ASC LIMIT n-1,1;

Please suggest some more interesting question related to "Data Structure and Algorithm" and "SQL"

If you have any doubt please feel free to connect with me on
Рекомендации по теме
Комментарии
Автор

Very easy way to explain thanks bhai.🙏

snehalatakhamankar
Автор

Thanks bhamiya 🔥 it's very imp for us

ankitjhajhria
Автор

bhai awaaz bht dabi dabi aari hai kuch sunai ni dera sahi se

rahulrawat