ACCP7.0S2优化myschool数据库设计第四章上机1-4

--上机1
select MAX(studentresult) as '最高分',MIN(studentresult) as '最低分' from result where
subjectid=(select subjectid from subject where subjectname='oop')
and examdate=(select MAX(examdate) from result 
where subjectid=(select subjectid from subject where subjectname='oop'))

--上机2
select subjectname from subject where subjectid in 
(select subjectid from subject where gradeid=(select gradeid from grade where gradename='S1'))

--上机3
select studentname from student where studentno not in(
select studentno from result where subjectid=(select subjectid from subject where subjectname='SQL') 
and examdate=(select MAX(examdate) from result where subjectid=(
select subjectid from subject where subjectname='java'))) and gradeid=1

--上机4
if exists(select studentno from student where gradeid=(select gradeid from grade where gradename='S1'))
begin
update student set gradeid=(select gradeid from grade where gradename='S2') where gradeid=(select gradeid from grade where gradename='S1')
end

你可能感兴趣的:(ACCP7.0S2优化myschool数据库设计第四章上机1-4)