- 找出所有员工当前(to_date=‘9999-01-01’)具体的薪水salary情况,对于相同的薪水只显示一次,并按照逆序显示
select distinct salary from salaries where to_date='9999-01-01' order by salary desc;
!!!注意:order by 语句必须放到最后
select salary from salaries where to_date='9999-01-01' group by salary order by salary desc;
对指定列分组查询即相同的只会显示一次,不会重复
- 查找最晚入职员工的所有信息
select * from employees order by hire_date desc limit 1;
limit 1 --> 表示从第2行数据开始
- 查找入职员工时间排名倒数第三的员工所有信息
select * from employees order by hire_date desc