The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

Problem 3: Task: Possible error?

Problem 3: Task: Possible error?

0
Votes
1
Answer

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 Answer

365 Team
0
Votes

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

It helps! Thank you.

1 month

You are very welcome!

1 month