天业务需要,网上没找到 最后写出来了就留个印以备查阅
#T1表中 A,B 列 至少三行都相同的数据
SELECT * FROM #T1 t1 WHERE
(
SELECT COUNT(*) FROM(
SELECT DISTINCT A,B FROM #T1 WHERE A=t1.A
) A
)=1
AND (SELECT DISTINCT COUNT(ID) FROM #T1 WHERE A=t1.A)>=3
ORDER BY t1.A
更多信息请查看IT技术专栏