找出所有员工当前(to_date=’9999-01-01’)具体的薪水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:
select salary from salaries
where to_date='9999-01-01'
group by salary
order by salary desc
答案2:
select distinct salary from salaries
where to_date='9999-01-01'
order by salary desc
本文介绍如何使用SQL查询来检索所有员工在特定日期的有效薪水记录,并确保相同薪水仅展示一次,同时按薪水降序排列。

被折叠的 条评论
为什么被折叠?



