我正在尝试在至少 2 行中找到几个月的员工生日
我试图将生日信息表与自身联合起来,假设我可以遍历它们 abd 得到多次出现的月份 问题是:如何获得重复多次的月份的生日?
SELECT DISTINCT e.EmployeeID, e.City, e.BirthDate
FROM Employees e
GROUP BY e.BirthDate, e.City, e.EmployeeID
HAVING COUNT(MONTH(b.BirthDate))=COUNT(MONTH(e.BirthDate))
UNION
SELECT DISTINCT b.EmployeeID, b.City, b.BirthDate
FROM Employees b
GROUP BY b.EmployeeID, b.BirthDate, b.City
HAVING ...
给定表:
| 1 | City1 | 1972-03-26|
| 2 | City2 | 1979-12-13|
| 3 | City3 | 1974-12-16|
| 4 | City3 | 1979-09-11|
预期结果 :
| 2 | City2 |1979-12-13|
| 3 | City3 |1974-12-16|