数据库(20180519)

2018-05-09  本文已影响0人  啦啦啦_79e6

✔检索选修课程包含LIU老师所授课程的学生学号

select sno

from sc

where cno in

(select cno

from c

where tname='LIU')

✔检索选修课程包含LIU老师所授全部课程的学生学号

select distinct sno

from sc X

where not exists

(select *

from sc y

where cno in

  (select cno

  from c

  where tname='LIU')

  and not exists

  (select *

  from sc z

  where z.sno=x.sno and z.cno=x.cno)

)


■求LIU老师所授课程的每门课程的学生平均成绩

select sc.cno,AVG(grade)

from sc,c

where sc.cno=c.cno

and tname='LIU'

group by sc.cno

上一篇下一篇

猜你喜欢

热点阅读