select count(*) from (select distinct sid from Table where bid='100') a join (select distinct sid from Table where bid='101') b on a.sid=b.sid (select distinct sid from Table where bid='102') c on a.sid=c.sid
select count(distinct sid) from student where sid in(select sid from student group by sid having count(bid)=3)
select count(sid) from (select sid from student where bid in('101','102') group by sid having count(1)=2) a left join (select sid from student where bid not in('101','102')) b on a.sid=b.sid where b.sid is null
select count(distinct sid) from student where sid in(select sid from student where bid in('100','101','102') group by sid having count(bid)=3)
from
(select distinct sid from Table where bid='100') a join
(select distinct sid from Table where bid='101') b on a.sid=b.sid
(select distinct sid from Table where bid='102') c on a.sid=c.sid
where sid in(select sid from student group by sid having count(bid)=3)
(select sid from student where bid not in('101','102')) b on a.sid=b.sid
where b.sid is null
from student
where sid in(select sid
from student
where bid in('100','101','102')
group by sid
having count(bid)=3)