-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path176_Second_Highest_Salary.sql
57 lines (46 loc) · 1.17 KB
/
176_Second_Highest_Salary.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
176. Second Highest Salary
Easy
491
252
Favorite
Share
SQL Schema
Write a SQL query to get the second highest salary from the Employee table.
+----+--------+
| Id | Salary |
+----+--------+
| 1 | 100 |
| 2 | 200 |
| 3 | 300 |
+----+--------+
For example, given the above Employee table, the query should return 200 as the second highest salary. If there is no second highest salary, then the query should return null.
+---------------------+
| SecondHighestSalary |
+---------------------+
| 200 |
+---------------------+
"""
# Write your MySQL query statement below
Select max(Salary) as SecondHighestSalary
From Employee
Where Salary < (SELECT max(Salary)
FROM Employee);
"""
Success
Details
Runtime: 157 ms, faster than 12.70% of MySQL online submissions for Second Highest Salary.
Memory Usage: N/A
"""
# Write your MySQL query statement below
Select max(Salary) as SecondHighestSalary
From Employee
Where Salary < (SELECT Salary
FROM Employee
ORDER BY Salary DESC
LIMIT 1);
"""
Success
Details
Runtime: 167 ms, faster than 7.38% of MySQL online submissions for Second Highest Salary.
"""