select aac001 from t where aae140 in ('01','04','05','07','08') group by aac001 having count (distinct aae140)=5
select aac001 from (select aac001,aae140 from t where aae140 in ('01','04','05','07','08') group by aac001,aae140 having count (*)=1) group by aac001 having count(*)=5
select * from (select wmsys.wmconcat(aae140) concat,count(*) cnum from t group by(acc001)) where concat='0104050708' and cnum=5
顶一个,不过感觉去掉distinct更准确
顶一个,不过感觉去掉distinct更准确 这个还真得加distinct,不然就不严谨了。
SELECT AAC001,COUNT(*) C FROM TABLE_NAME WHERE AAE140 IN ('01','04','05','07','08') GROUP BY AAE001 HAVING COUNT(*)=5
where aae140 in ('01','04','05','07','08')
group by aac001
having count (distinct aae140)=5
from
(select wmsys.wmconcat(aae140) concat,count(*) cnum
from t
group by(acc001))
where concat='0104050708' and cnum=5
这个还真得加distinct,不然就不严谨了。
WHERE AAE140 IN ('01','04','05','07','08')
GROUP BY AAE001
HAVING COUNT(*)=5