select * from employees WHERE hire_date = (SELECT max(hire_date) from employees)
select * from employees
where hire_date = (
select distinct hire_date from employees order by hire_date desc limit 2,1
)
;
select s.* ,d.dept_no
from salaries as s
join dept_manager as d
on s.emp_no=d.emp_no
where s.to_date = '9999-01-01'
and d.to_date='9999-01-01';
SELECT e.last_name, e.first_name, d.dept_no
FROM employees as e inner JOIN dept_emp as d
on e.emp_no = d.emp_no;
SELECT ep.last_name, ep.first_name, dp.dept_no
FROM employees ep
LEFT JOIN dept_emp dp
ON ep.emp_no = dp.emp_no
SELECT emp_no, COUNT(emp_no) as t
from salaries
GROUP by emp_no HAVING t>15;
SELECT DISTINCT salary
from salaries
where to_date = '9999-01-01'
order by salary DESC;
select emp_no
from employees
where emp_no not in (select emp_no from dept_manager)
SELECT de.emp_no, dm.emp_no AS manager_no
FROM dept_emp AS de INNER JOIN dept_manager AS dm
ON de.dept_no = dm.dept_no
WHERE dm.to_date = '9999-01-01' AND de.to_date = '9999-01-01' AND de.emp_no <> dm.emp_no