2020-06-03
阅读量:
870
薪水
一、题目描述
获取当前(to_date='9999-01-01')薪水第二多的员工的emp_no以及其对应的薪水salary
CREATE TABLE salaries
(
emp_no
int(11) NOT NULL,
salary
int(11) NOT NULL,
from_date
date NOT NULL,
to_date
date NOT NULL,
PRIMARY KEY (emp_no
,from_date
));
二、解题思路:
1、先对to_date='9999-01-01'时间下薪水salary进行去重排序,选出排名第二多的薪水;
2、然后对salaries中薪水进行判断是否等于【排名第二多的薪水】
from salaries
where to_date='9999-01-01' and salary in (
select distinct salary
from salaries
where to_date='9999-01-01'
order by salary desc
limit 1,1)
;






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论