本题目要求编写 Insert语句,
检索所授每门课程平均成绩均大于70分的教师姓名,并将检索的值插入一个新的教师表faculty表
中
表结构:
请在这里写定义表结构的SQL语句。例如:
CREATE TABLE `cou` (
`cno` char(4) NOT NULL,
`cname` varchar(30) NOT NULL,
`credit` smallint(6) DEFAULT NULL,
`ptime` char(5) DEFAULT NULL,
`teacher` char(10) DEFAULT NULL,
PRIMARY KEY (`cno`)
)CREATE TABLE `sc` (
`sno` char(4) NOT NULL,
`cno` char(4) NOT NULL,
`grade` decimal(6,1) DEFAULT NULL,
PRIMARY KEY (`sno`,`cno`),
CONSTRAINT `fk_sc_cno` FOREIGN KEY (`cno`) REFERENCES `cou` (`CNO`)
);CREATE TABLE `faculty` (
`tname` char(10) DEFAULT NULL
)
表样例
请在这里给出上述表结构对应的表样例。例如
cou
表:
sc
表:
输出样例:
教师表faculty表
,如下:
insert into faculty
select teacher tname
from cou c1
where cno in (select cno from sc group by cno having avg(grade) > 70)
group by teacher
having count(*) = (select count(*) from cou c2 where c1.teacher = c2.teacher)