Complete-SQL-Database-Bootcamp-Zero-to-Mastery
Complete-SQL-Database-Bootcamp-Zero-to-Mastery copied to clipboard
Correction of the question tense
https://github.com/mobinni/Complete-SQL-Database-Bootcamp-Zero-to-Mastery/blob/3fa6008ea396a5bcca4180ccdd589500b84785f6/SQL%20Deep%20Dive/Having/answers.sql#L16
Please change the question to Show me all the employees that have had more than 15 salary changes and have ever worked in the department development
The original sentence conveys showing the employees that are currently working in the "Development" department which is not the intended result and need an extra de.to_date > NOW()
condition:
SELECT e.emp_no, count(s.from_date) as "amount of raises"
FROM employees as e
JOIN salaries as s USING(emp_no)
JOIN dept_emp AS de USING(emp_no)
WHERE de.to_date > NOW() And de.dept_no = 'd005'
GROUP BY e.emp_no
HAVING count(s.from_date) > 15
ORDER BY e.emp_no;