我试图更好地理解以下查询的答案:https://www.w3resource.com/sql-exercises/sql-subqueries-exercise-22.php
答案是:
SELECT
departments.department_id, result1.total_amt
FROM
departments,
(SELECT employees.department_id, SUM(employees.salary) total_amt
FROM employees
GROUP BY department_id) result1
WHERE
result1.department_id = departments.department_id;
但是,我不明白为什么我需要最后一部分:
WHERE result1.department_id = departments.department_id