I need to find the department that has the oldest employee. My plan is to merge everything into one big table and try to sort the employees by age, then find the department that has the oldest employee, and find the manager for that department. Currently this is my query:
SELECT * FROM employees emp JOIN dept_emp de ON emp.emp_no=de.emp_no JOIN departments dep ON de.dept_no=dep.dept_no JOIN dept_manager depm ON dep.dept_no=depm.dept_no JOIN employees emp2 ON depm.emp_no=emp2.emp_no -- some part of query is lost here -- DESC LIMIT 0, 1
Unfortunately, when I run that, it's saying that column 'birth_date' is ambiguous to sort - which makes sense bc I'll have 2 columns with the same date.