首页 > TAG信息列表 > SecondHighestSalary
Mysql训练:第二高的薪水(IFNULL,OFFSET,LIMIT)
编写一个 SQL 查询,获取 Employee 表中第二高的薪水(Salary) 。 +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ 例如上述 Employee 表,SQL查询应该返回 200 作为第二高的薪水。如果不存在第二高的薪水,#力扣 LeetCode176. 第二高的薪水 @FDDLC
题目描述: https://leetcode-cn.com/problems/second-highest-salary/ 方法一: select (select distinct Salary from Employee order by Salary desc limit 1,1) as SecondHighestSalary; 方法二: select max(Salary) as SecondHighestSalary from (select Salary from EmpLeetCode 176 第二高的薪水
题目描述: sql语句: 使用子查询和limit语句 select (select distinct Salary from Employee order by Salary desc limit 1,1) as SecondHighestSalary;176. 第二高的薪水
sql Create table If Not Exists Employee (Id int, Salary int) Truncate table Employee insert into Employee (Id, Salary) values ('1', '100') insert into Employee (Id, Salary) values ('2', '200') insert into Employeeleetcode176 第二高的薪水 Second Highest Salary
编写一个 SQL 查询,获取 Employee 表中第二高的薪水(Salary) 。 创建表和数据: drop table Employee;Create table If Not Exists Employee (Idint, Salary int);insert into Employee (Id, Salary) values('1', '100');insert into Employee (Id, Salary) values('2