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 the above Employee table, the second highest salary is 200. If there is no second highest salary, then the query should return null.

# Write your MySQL query statement below
select max(Salary) from Employee where Salary < (select max(Salary) from Employee);

  

时间: 2024-10-11 07:29:30

LeetCode 176 Second Highest Salary mysql,select 嵌套 难度:1的相关文章

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 

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][SQL]Nth Highest Salary

Nth Highest Salary Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ For example, given the above Employee table, the nth highe

[LeetCode][SQL]Second Highest Salary

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

LeetCode:Second Highest Salary - 第二高的工资

1.题目名称 Second Highest Salary(第二高的工资) 2.题目地址 https://leetcode.com/problems/second-highest-salary/ 3.题目内容 现在有一张记录了Id(主键)和Salary(工资)的表,求出其中第二高的工资.如果不存在第二高的工资,返回null. +----+--------+ | Id | Salary | +----+--------+ | 1  | 100    | | 2  | 200    | | 3  | 

LeetCode:Nth Highest Salary - 第N高的工资

1.题目名称 Nth Highest Salary(第N高的工资) 2.题目地址 https://leetcode.com/problems/nth-highest-salary/ 3.题目内容 与这道题目相比,上一道题目"Second Highest Salary"是本题在N=2时的特例.两道题目的表结构完全一样,Employee表的结构如下: +----+--------+ | Id | Salary | +----+--------+ | 1  | 100    | | 2  |

【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

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 a

【Leetcode】 Second Highest Salary

题目链接: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 the above Empl