我有一个表Employer,其字段为EmployerID和EmployeeID。我需要打印超过2名员工的所有雇员,即count(EmployerID)> 2按EmployerID分组时。我到目前为止能够根据给定的条件对事件进行计数但无法进行过滤。
按EmployerID从雇主组中选择EmployerID,count(EmployerID)
答案 0 :(得分:1)
SELECT EmployerID,COUNT(EmployeeID)
FROM EMPLOYER
GROUP BY EmployerID
HAVING COUNT(EmployeeID) > 2