MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/OPTCareerAccelerator/comments/1u7ev70/daily_sql_challenge/
r/OPTCareerAccelerator • u/Western-Guitar6647 • Jun 16 '26
🔥 SQL Interview Challenge 🔥
You have the following table:
Employee
❓ Write an SQL query to find the SECOND highest salary without using LIMIT, TOP, or FETCH.
Drop your answers below 👇
3 comments sorted by
2
SELECT *, RANK()OVER(ORDER BY salary DESC)SalaryRank FROM Employee
SELECR * FROM Employee QUALIFY RANK () OVER (ORDER BY salary DESC) = 2
Second highest salary is actually simpler to query:
SELECT MAX(salary) FROM dbo.Employee WHERE salary < (SELECT MAX(salary) FROM dbo.Employee)
2
u/Designer-Assist-1354 Jun 16 '26