您的位置:首页 > 数据库 > MySQL

mysql中,编写一个 SQL 查询,获取 Employee 表中第 n 高的薪水(Salary)。

2020-07-14 06:25 316 查看

标题:mysql中,编写一个 SQL 查询,获取 Employee 表中第 n 高的薪水(Salary)。

一、题目

二、解题

CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
declare result int;
set result=N-1;
RETURN (
# Write your MySQL query statement below.
select ifnull(
(
select distinct salary
from employee
order by salary desc
limit result,1
)
,null)
);
END
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐