
#Zadanie 1
SELECT departments.dept_name, COUNT(*) as nmb FROM
  dept_manager INNER JOIN departments ON dept_manager.dept_no = departments.dept_no
GROUP BY departments.dept_name
ORDER BY nmb DESC, departments.dept_name;


#Zadanie 2
SELECT COUNT(*) as nmb FROM
  employees JOIN salaries ON employees.emp_no = salaries.emp_no
  WHERE employees.birth_date<STR_TO_DATE('5, 3, 1953', '%d,%m,%Y') AND
employees.gender='M' AND salaries.to_date>NOW();

#Zadanie 3
SELECT employees.last_name, DATEDIFF(dept_manager.from_date, employees.hire_date) as dayDiff FROM
  dept_manager JOIN employees ON dept_manager.emp_no = employees.emp_no
WHERE dept_manager.to_date>NOW()
ORDER BY dayDiff DESC, employees.last_name;
