SELECT dep.depName, SUM(worker.salary) as total
FROM team, worker
WHERE worker.depID = dep.depID
GROUP BY dep.depID
SELECT dep.depName, SUM(manager.salary) as total
FROM manager, dep
WHERE manager.depID = dep.depID
GROUP BY team.depID
我尝试了一些类似的东西:SELECT dep.depName, SUM(manager.salary)+SUM(worker.salary) as total,但它给了我一些奇怪的输出,它添加了 N 个元素 N 次。