第1个回答 2010-03-31
1.select SNAME from STUDENT where SNO in
(select SNO from SC where GRADE>90 group by SNO having count(*)>=2)
2.select a.SNAME from STUDENT a,(select SNO from SC where GRADE>90 group by SNO having count(*)>=2) b
where a.SNO=B.SNO
3.select a.SNAME from STUDENT a,SC b where a.SNO=b.SNO and b.GRADE>90
group by a.SNAME having count(*)>2
解释:select SNO from SC where GRADE>90 group by SNO having count(*)>=2 这句就代表按照SNO汇总,分数90以上,并且条数(也就是有两科)也是2门以上(包含2门),如果只是2门以上,你可以把=号去掉本回答被提问者采纳
第2个回答 2010-03-31
第一种:
select t1.sname from STUDENT t1 where (select count(*) from SC t2 where t2.sno=t1.sno and
t2.grade>90)>2
第二种:
select t1.sname from STUDENT t1 where t1.sno in
(select sno from SC
where (select count(*) from SC t2
where t2.sno=t1.sno
and t2.grade>90
)>2
)
第三种:
select t1.sname from STUDENT t1
where t1.sno in
(select t2.sno from SC t2 where t2.grade>90 group by t2.sno having count(*)>2)
楼上的写的不错,呵呵
第3个回答 2010-03-31
特别推荐:
select t.*, c.*, s.* from
student t , course c , sc s where t.sno = s.sno and c.cno = s.cno
and s.sno in ( select sno from (
select sno ,count(*) from sc where grade > 90 group by sno having count(*) > 1 ))
第4个回答 2010-03-31
select *
from student A,
(select sno
from sc
where grade > 90
group by sno
having count(sno) > 1) B
where A.sno = B.sno