select employee_name from
(SELECT employee_id, COUNT(*) AS total FROM employee_tour
GROUP BY employee_id) as tb
inner join employee on tb.id_employee = employee.id_employee
where tb.total = (select count (*) from tour)
SELECT e.*
FROM employee e
JOIN (SELECT employee_id, COUNT(*) AS employee_tours
FROM employee_tour
GROUP BY employee_id) et ON e.employee_id = et.employee_id
CROSS JOIN (SELECT COUNT(*) AS all_tours
FROM tour) t
WHERE employee_tours = all_tours
3条答案
按热度按时间n3schb8v1#
试试看。。
hi3rlvi22#
我将使用两个联接—一个用于统计所有旅行的聚合查询,另一个用于统计员工参加的旅行次数的聚合查询,然后比较它们:
pgvzfuti3#
可以使用join语句
请参阅加入