Skip to content

176. Second Highest Salary

View on LeetCode

Approach: Second max = max of salaries excluding the overall max (via NOT IN subquery).

Complexity: O(n) time with two scans (DB-dependent)

sql
select max(Salary) from Employee where Salary not in (select max(Salary) from Employee)