Skip to content

Commit 141e4ba

Browse files
authored
Merge pull request #19 from JinkeCao/master
modified: second-highest-salary.sql
2 parents 4451c51 + 5000832 commit 141e4ba

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

MySQL/second-highest-salary.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
# For example, given the above Employee table, the second highest salary is 200. If there is no second highest salary, then the query should return null.
1414
#
1515
# Write your MySQL query statement below
16-
SELECT MAX(Salary) FROM Employee
17-
WHERE Salary NOT IN (SELECT MAX(Salary) FROM Employee)
16+
select (SELECT MAX(Salary) FROM Employee WHERE Salary NOT IN (SELECT MAX(Salary) FROM Employee)) SecondHighestSalary;
17+
# or
18+
SELECT (SELECT Salary FROM Employee GROUP BY Salary ORDER BY Salary DESC LIMIT 1,1) SecondHighestSalary;

0 commit comments

Comments
 (0)