分别在SQL Server2000和Access中用SQL语句进行如下操作 急!!!

2025-04-29 04:03:07
推荐回答(2个)
回答1:

------回答(sql2000的)--------
--学号 门数
select Sno,count(distinct Cno) as num from SC group by Sno
--超过一门
select Sno from SC group by Sno having count(distinct Cno)>1
--1 2 3 成绩排序
select Sno,Grade from SC where Cno in ('001','002','003') order by Sno,Grade desc
--100分
select S.Sno,S.Sname from S,SC
where S.Sno=SC.Sno and SC.Grade=100
--001 002
select S.Sname,S.Sage from S,SC A,SC B where S.Sno=A.Sno and S.Sno=B.Sno and A.Cno='001' and B.Cno='002'
--选课学生
select S.Sno,S.Sname,C.Cname,SC.grade from S,SC,C where S.Sno=SC.Sno and SC.Cno=C.Cno
--所有学生
select S.Sno,Sname,C.Cname,SC.grade from S left join SC on S.Sno=SC.Sno left join C on SC.Cno=C.Cno
--子查询
--张三
select SC.Sno,C.Cname,SC.grade from SC,C where SC.Cno=C.Cno and SC.Sno in (select Sno from S where Sname='张三')
--某一科 比张三高
select sno,sname,ssex from s where sno in( select b.sno from sc a,sc b where a.cno=b.cno and a.sno=(select sno from s where sname='张三'') and b.grade>a.grade)
--全比张三高
select sno,sname,ssex from s where sno not in( select b.sno from sc a,sc b where a.cno=b.cno and a.sno=(select sno from s where sname='d') and b.grade<=a.grade)

--没有选课学生
select Sno,Sname from S where Sno not in(select distinct Sno from SC)

回答2:

不让我修改了
只能重新注册一个继续
--2.5 0.95倍
update sc
set Grade=Grade*0.95
where
cno in(select cno from c where cmark=2.5)
--选修了所有课程
select
sno,sname
from
s
where
sno in(
select
sno
from
sc
group by sno
having count(distinct cno)=(select count(distinct cno) from c))

有什么不满足你要求的提出来 我再改 大家共同学习