Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Have a good contributing!
- [511. Game Play Analysis 1](./leetcode/easy/511.%20Game%20Play%20Analysis%201.sql)
- [577. Employee Bonus](./leetcode/easy/577.%20Employee%20Bonus.sql)
- [595. Big Countries](./leetcode/easy/595.%20Big%20Countries.sql)
2. [Medium](./leetcode/medium/)
- [176. Second Highest Salary](./leetcode/medium/176.%20Second%20Highest%20Salary.sql)

## License

Expand Down
19 changes: 19 additions & 0 deletions leetcode/medium/176. Second Highest Salary.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Table: Employee

+-------------+------+
| Column Name | Type |
+-------------+------+
| id | int |
| salary | int |
+-------------+------+
id is the primary key (column with unique values) for this table.
Each row of this table contains information about the salary of an employee.


Write a solution to find the second highest distinct salary from the Employee table. If there is no second highest salary, return null (return None in Pandas)
*/

SELECT MAX(e1.salary) AS SecondHighestSalary
FROM Employee AS e1
WHERE e1.salary < (SELECT MAX(e2.salary) FROM Employee AS e2)