14
Student(SNO,Name,SEX,BIRTHDAY,CLASS); Teacher(Tno,Name,Sex,Birthday,Prof,DEPART); Course(CNO,CNAME,Tno); SCORE(SNO,CNO,DEGREE); (3)查询“201901”班所选课程的平均分 Select yo,avg(y.degree) from student x,score y where x.sno=y.sno and x.class=’201901’ group by yo;
10
2、用sql完成以下各项操作: 7)找出没有使用天津产的零件的工程号码; select jno from j where not exists(select * from spj,s where spj.sno=s.sno and s.city='天津' and spj.jno=j.jno)
9
⑸求至少用了S1供应商所供应的全部零件的工程号 JNO。 答:关系代数 ∏JNO,PNO(SPJ)÷∏PNO(SNO=‘S1’(SPJ))
SQL:
select distinct jno from spj spjx where not exists(select * from spj spjy where spjy.sno='s1' and not exists(select * from spj spjz where spjz.pno=spjy.pno and spjz.jno=spjx.jno))
6
或者 select jno from j where jno not in(select jno from spj,s,p where spj.pno=p.pno and spj.sno=s.sno and p.color='红' and s.city='天津')