我必須讓所有的job_titles的列表,並在那裏工作的人工資的總和......爲什麼這個SQL字符串不工作?
我使用此:
SELECT j.job_title, SUM(e.salary)
FROM jobs j LEFT JOIN employees e ON e.job_id = j.job_id
GROUP BY j.job_title;
OK,但現在我得同一名單還要綜合考慮城市...
它好好嘗試一下工作...:/
SELECT j.job_title, SUM(e.salary), d.department_id, l.city
FROM departments d LEFT JOIN employees e ON e.department_id = d.department_id LEFT JOIN locations l
ON l.location_id = d.location_id LEFT JOIN jobs j ON e.job_id = j.job_id
GROUP BY l.city;
爲什麼會是什麼?
也許你可以試試'INNER d.department_id所以加入'而不是。 –