1. 自定义一个函数,实现如下功能:对于一个给定的课程号,查询没有修读该课程的学生名字。
表值函数就是返回一个表
create function badstudent(@Cno char(3)) returns table
as
return (
select SName
from Student
where not exists(select * /*选修次课程的同学就不选*/
from sc
where sc.SNo = Student.SNo and CNo = @Cno)
)
select *
from badstudent('001')