牛客 SQL 练习
https://www.nowcoder.com/ta/sql
SQL 1.查找最晚入职员工的所有信息
select * from employees e order by e.hire_date desc limit 0,1
SQL 2.查找入职员工时间排名倒数第三的员工所有信息
select * from (select * from employees e order by e.hire_date desc limit 2, 1)
SQL 3. 查找各个部门当前领导当前薪水详情以及其对应部门编号
select s.emp_no, s.salary, s.from_date, s.to_date, d.dept_no from salaries s left join dept_manager d on s.emp_no = d.emp_no where s.to_date = '9999-01-01' and d.to_date = '9999-01-01'
SQL 4.查找所有已经分配部门的员工的last_name和first_name以及dept_no
select e.last_name, e.first_name, d.dept_no from employees e inner join dept_emp d on e.emp_no = d.emp_no
SQL 5.查找所有员工的last_name和first_name以及对应部门编号dept_no,也包括暂时没有分配具体部门的员工
select e.last_name, e.first_name, d.dept_no from employees e left join dept_emp d on e.emp_no = d.emp_no
SQL 6.查找所有员工入职时候的薪水情况
SQL 15.查找 employees 表
select * from employees e where e.emp_no % 2 = 1 and e.last_name != 'Mary' order by e.hire_date desc