Problem 3: Task: Possible error?
Hi!
In the video lesson of the link provided, I think there is a mistake:
At 1:33 it is suggested to select from_date from t_dept_emp table.
However, in the solution of the problem, the right choice was to select from_date from t_salaries table.
I wanted to confirm if the answer were going to be different, and they actually are.
Please correct me if I am wrong, but If I am not, then why we cannot select from_date from t_dept_emp table?
Thank you so much once again!
This is my code:
SELECT
e.gender,
d.dept_name,
ROUND(AVG(s.salary), 2) AS average_salary,
YEAR(de.from_date) AS calendar_year
FROM
t_employees e
JOIN
t_salaries s ON e.emp_no = s.emp_no
JOIN
t_dept_emp de ON s.emp_no = de.emp_no
JOIN
t_departments d ON de.dept_no = d.dept_no
WHERE
YEAR(de.from_date) <= 2002
GROUP BY d.dept_name , e.gender , YEAR(de.from_date)
ORDER BY d.dept_name;
Best,
Martin