1. 程式人生 > >山東大學資料庫實驗八

山東大學資料庫實驗八

1.create table test81 as
(select pub.STUDENT_course.SID,pub.STUDENT.DNAME,max(score) as score
from pub.STUDENT,pub.STUDENT_COURSE,pub.COURSE
where pub.STUDENT_COURSE.SID=pub.student.sid
and pub.STUDENT_COURSE.CID=pub.course.cid
and pub.COURSE.NAME='作業系統'
and dname is not null
group by pub.STUDENT_COURSE.SID,pub.STUDENT.DNAME)
create table test811 as
(select dname,round(avg(score),0) as avg_os_score
from test81
group by dname)
create table test812 as(
select dname,pub.STUDENT_COURSE.SID,max(score) as score
from pub.STUDENT,pub.STUDENT_COURSE,pub.COURSE
where pub.STUDENT_COURSE.SID=pub.student.sid
and pub.STUDENT_COURSE.cid=pub.course.cid
and pub.COURSE.NAME='資料結構'
and dname is not null
group by dname,pub.STUDENT_COURSE.SID)
create table test813 as
(select dname,round(avg(score),0) as avg_ds_score
from test812
group by dname)
create table test8_01 as
(select *
from test811 natural left join test813)
2。create table test821 as(
select pub.STUDENT.SID,pub.STUDENT.NAME,dname,max(score) as ds_score
from pub.STUDENT,pub.STUDENT_COURSE,pub.COURSE
where pub.STUDENT.SID=pub.student_course.sid
and pub.STUDENT_COURSE.CID=pub.course.cid
and pub.COURSE.NAME='資料結構'
and dname='電腦科學與技術學院'
group by pub.STUDENT.SID,pub.STUDENT.NAME,dname)
create table test822 as(
select pub.STUDENT.SID,pub.STUDENT.NAME,dname,max(score) as os_score
from pub.STUDENT,pub.STUDENT_COURSE,pub.COURSE
where pub.STUDENT.SID=pub.student_course.sid
and pub.STUDENT_COURSE.CID=pub.course.cid
and pub.COURSE.NAME='作業系統'
and dname='電腦科學與技術學院'
group by pub.STUDENT.SID,pub.STUDENT.NAME,dname)
create table test8_02 as
(select *
from test821 natural join test822)
3.create table test8_03 as
(select *
from test821 natural full join test822)
4.create table test841 as(
select *
from pub.STUDENT
where dname='電腦科學與技術學院')
create table test842 as
(select *
from test841 natural full outer join test8_03)
create table test8_04 as
(select sid,name,dname,ds_score,os_score
from test842)