Second & Nth Highest Salary Problems
Learn Second & Nth Highest Salary Problems (Advanced SQL Interview Problems, MySQL) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Introduction Classic question: return the Nth highest distinct salary. The cleanest MySQL 8 answer ranks salaries with DENSE_RANK() , which gives tied salaries the same rank and no gaps.
More lessons in Advanced SQL Interview Problems
- Find & Remove Duplicate Records
- Employees Earning More Than Their Manager
- Department-wise Highest Salary & Top 3 per Department
- Running Total & Moving Average Problems
- Consecutive Dates, Missing Numbers & Gaps and Islands
- Employee Hierarchy & Recursive Organizational Tree
- Customers Who Never Ordered
- Most Frequently Purchased Product & Monthly Revenue
- Year-over-Year Growth & Retention Analysis