Last answered:

20 Sept 2020

Posted on:

17 Sept 2020

0

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;

1 answers ( 0 marked as helpful)
Instructor
Posted on:

20 Sept 2020

0
Hi Harold! Great to have you in the course and thanks for reaching out! The tasks requires from us to compare the salaries of certain individuals in the entire company. That's why the only way in which we can obtain the correct output is by using the start date from the salaries table. Hope this helps.
Best,
Martin

Submit an answer