From dcad29f56cad9d7ff452a2a5b425955e185e49ce Mon Sep 17 00:00:00 2001 From: ivanbyone Date: Sun, 29 Jun 2025 12:39:34 +0300 Subject: [PATCH] task #176 --- README.md | 2 ++ .../medium/176. Second Highest Salary.sql | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 leetcode/medium/176. Second Highest Salary.sql diff --git a/README.md b/README.md index 89e622a..6132302 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/leetcode/medium/176. Second Highest Salary.sql b/leetcode/medium/176. Second Highest Salary.sql new file mode 100644 index 0000000..6f4445d --- /dev/null +++ b/leetcode/medium/176. Second Highest Salary.sql @@ -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)