1.查找最晚入职员工的所有信息 子查询 max
select * from employees
where hire_date=
(select max(hire_date) from employees)
2. 查找入职员工时间排名倒数第三的员工所有信息 order desc 从小到大排序
limit m,n 从第m个位置,查询出n条数据
select *
from employees
order by hire_date desc limit 2,1;
3. 查找各个部门当前(to_date='9999-01-01')领导当前薪水详情以及其对应部门编号dept_no
内连接 where and
select salaries.emp_no,salaries.salary,salaries.from_date,salaries.to_date,dept_manager.dept_no
from salaries inner join dept_manager
on dept_manager.emp_no = salaries.emp_no
where dept_manager.to_date = '9999-01-01'
and salaries.to_date = '9999-01-01';
4. 查找薪水涨幅超过15次的员工号emp_no以及其对应的涨幅次数t
count, as group by having
select emp_no, count(emp_no) as t
from salaries
group by emp_no having t > 15
5. 找出所有员工当前(to_date='9999-01-01')具体的薪水salary情况,对于相同的薪水只显示一次,并按照逆序显示.
distinct
select distinct sl.salary
from salaries sl
where to_date = '9999-01-01'
order by sl.salary desc