176. Second Highest Salary

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(select max(Salary) from Employee  where Salary < (select max(Salary) from Employee )) as SecondHighestSalary
时间: 2024-07-30 19:35:09

176. Second Highest Salary的相关文章

LeetCode 176 Second Highest Salary mysql,select 嵌套 难度:1

https://leetcode.com/problems/second-highest-salary/ 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 th

Leetcode 176 Second Highest Salary

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 second highest salary is 

176. Second Highest Salary(Easy)

Source of the question 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 qu

LeetCode_Mysql_Second Highest Salary

176. Second Highest Salary 1. 问题描写叙述: 写一个sql语句从 Employee 表里获取第二高位的工资. 2. 解决思路: 这道题非常easy,就当热身了.首先用max找到最高工资. 然后去找小于最高工资里的最高工资就是第二高的工资. 3. sql语句: select Max(Salary) from Employee where Salary < (select Max(Salary) from Employee) 4. 执行时间: 希望多多交流指正!

LeetCode:Department Highest Salary - 部门内最高工资

1.题目名称 Department Highest Salary(部门内最高工资) 2.题目地址 https://leetcode.com/problems/rising-temperature 3.题目内容 表Employee包括四列:Id.Name.Salary.DepartmentId +----+-------+--------+--------------+ | Id | Name  | Salary | DepartmentId | +----+-------+--------+--

leetcode-184-Department Highest Salary 优化记录

题目 The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id. +----+-------+--------+--------------+ | Id | Name | Salary | DepartmentId | +----+-------+--------+--------------+ | 1 |

[LeetCode]-DataBase-Department Highest Salary

The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id. +----+-------+--------+--------------+ | Id | Name | Salary | DepartmentId | +----+-------+--------+--------------+ | 1 | Jo

LeetCode - Second Highest Salary

Description: 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 second highe

【leetcode】Second Highest Salary

原题如下: 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 second highest sala