27,581
社区成员




select sno from sc where cno='1' and sno in(select sno from sc where cno='3');
Create table #SC
(
Sno varchar(255),
Cno varchar(255),
Grade decimal(4,1)
)
insert into #SC
select '95001','1',92
union all
select '95001','2',85
union all
select '95001','3',88
union all
select '95002','1',90
union all
select '95003','1',82
union all
select '95003','3',85
select Sno
from #SC a
where exists (select Sno,count(cno) from #SC b where a.Sno = b.sno group by sno having count(cno)=2 )
group by Sno
select Sno
from SC a
where Cno in('1','3')
and not exists(select 1 from SC b where b.Sno=a.Sno and b.Cno not in('1','3'))
group by Sno
having count(1)=2