SQL Challenge: Department Salary Ranking
Find the 2nd Highest Salary: SQL Interview Challenge
How to Find the 2nd Highest Salary in SQL
π₯ SQL INTERVIEW CHALLENGE
Youβre given this table:
employees
id | name | department | salary
--|----------|------------------|------
1 | Rahul | IT | 80000
2 | Priya | HR | 60000
3 | Amit | IT | 95000
4 | Neha | HR | 75000
5 | Ravi | IT | 90000
π― Your challenge:
π Find the 2nd highest salary in each department.
β Don't use Python.
β Don't Google it.
β±οΈ Give yourself 5 minutes.
Think about it before looking at the comments π
π‘ Hint:
"ROW_NUMBER()"
"RANK()"
"DENSE_RANK()"
Which one would you use?
A) ROW_NUMBER()
B) RANK()
C) DENSE_RANK()
D) Something else ( Order By, Limit, Offset, Max, Sub- Query )
π Drop your answer in the comments.
Iβll share the solution + explanation in the next post.
Save this for your next SQL interview.
Subscribe @tech_jroshan for more content on SQL, Power BI, Python, Data Analytics, Data Science, AI, and Machine Learning & Automation.
Database, LearningSQL ,TechCareer, Analytics, MachineLearning ,SQLInterview, TechEducation, SQLSeries ,Statistics, Career, TechCareer, DataCareer, tech_jroshan, EDA ,SQL ,Mysql ,Database, RelationalDatabase ,SqlInterviewQuestions, ProblemSolving ,DataAnalytics , DataCleaning, DataScientist, MachineLearningTips
#DataA
nalysis #DataS
cience #Pytho
n #Inter
viewQuestions #Panda
s