SQL面试题
时间:2014-05-22 17:34:57
收藏:0
阅读:351
有3个表S,C,SC
S(SNO, SNAME)代表(学号,姓名)
C(CNO,CNAME,CTEACHER)代表(课号,课名,教师)
SC(SNO, CNO, SCGRADE)代表(学号,课号成绩)
问题:
1、找出没选过‘黎明“老师的所有学生姓名。
2、列出两门以上(含2门)不及格学生姓名及平均成绩。
3、即学过1号课程有学过2号课所有学生的姓名。
请用标准SQL语言写出答案,方言也行(请说明是使用什么方言)。
1、select sname from s join sc on (s.sno = sc.sno) join c on (c.no = sc.cno) where c.cteacher <> ‘黎明‘;
2、select sname from s where sno in (select count(*) from sc where scgrade< 60 group by sno having count(*) >= 2);
3、select sname from s where sno in (select sno from sc where cno = 1 and sno in(select sno from sc where cno =2));
评论(0)