SELECT MAX(s.name || ' ' || s.surname) as "Supervisor",
MAX(s.mobile_nr) as "Telephone",
COUNT(w.id_worker) as "Total subworkers"
FROM supervisor s
INNER JOIN worker w
ON s.id_supervisor=w.id_supervisor
INNER JOIN maintainer m
ON w.id_maintainer=m.id_maintainer
GROUP BY s.id_supervisor
HAVING COUNT(w.id_worker) > 1
1条答案
按热度按时间t3irkdon1#
使用
HAVING
子句,而不是(不相关的)子查询:GROUP BY
,而不是使用姓名,因为可能有两个人同名(如果他们共用一个办公室,则使用相同的电话号码)。*