select H1.id from (select id, count(name) as cnt from T where name in ('A' ,'B') group by id) H1 inner join (select id, count(name) as cnt from T group by id) H2 where H1.id = H2.id and H1.cnt = H2.cnt;
speedofstephen
2020-02-18 16:23:19 +08:00
错了 好像还得加上 where H1.cnt=2
shyrock
2020-02-18 16:24:22 +08:00
select distinct(id) from T MINUS select distinct(id) from T where name in ('C','D',...)