select sname from student where not exists (select * from course where not exists (select * from sc where sno =student.sno and cno=course.cno); 最内部的 select * from sc where sno=student.sno and cno = course.cno是查询出所有已经选择过课程的学生及相应课程,select * from cour
一.SQL语言查询选修了全部课程的学生的学号和姓名. 两种解决途径: 第一种: 我们可以表示为在SC表中某个学生选修的课程数等于C表中课程总数.相应的SQL语言如下: select S#,SNAME from S where S# in (select S# from SC group by S# --根据Sno分组,统计每个学生选修了几门课程.如果等于C表课程的总数,就是我们要找的S# having count(*) = (select count(*) from C))--统计C表中共有几门
前几天求职面试,有一道SQL题:给出三个表:学生.课程.成绩,求选修了所有课程的学生. 一道看似很简单的问题,把我难住了,我改了又改,涂涂画画,抓耳挠腮,因为试卷没有多少空白位置了,最后只好放弃.心情大受影响,尽管最后还是获得offer. 但是心中有愧呀! 于是在机器上试了试: 先建好表 use test; go create table student(sno varchar(50) not null,name varchar(50) not null); insert into studen
29.查询选修编号为"3-105"课程且成绩至少高于选修编号为"3-245"的同学的Cno.Sno和Degree,并按Degree从高到低次序排序. select tname,prof from teacher where depart = '计算机系' and prof not in ( select prof from teacher where depart = '电子工程系') 30.查询选修编号为"3-105"且成绩高于选修编号为&q
Course表如下: 查询出每门课都大于80 分的学生姓名有两种方法. 1.select distinct name from Course where name not in (select distinct name from Course where score<=80) 2.select name from Course group by name having min(score)>80
时间:2017-09-11 整理:byzqy 题目:用一条SQL语句查询出每门课都大于80分的学生姓名. 最近面试C#开发工程师,碰到上面这个考数据库的题目,自己感觉有点难度,没有思路,现将找到的解决方案整理如下: 文件:SQLQuery1.sql /* 环境:Microsoft SQL Server 2012 工具: Microsoft SQL Server Management Studio 数据库: Interview 数据表: grade 详情: name class score 张三
方法1: 查出科目成绩有小于80分的学生姓名,再约束并去重学生不等于查出来的姓名 select distinct A.name from t_score A where A.name not in(select distinct B.name from t_score B where B.fenshu <=80) 方法2: 按学生姓名分组,且最小的分数要大于80分 select A.name from t_score A group by A.name having min(A.fenshu)>
33. 查询成绩比该课程平均成绩低的同学的成绩表. select * from score a where a.degree between 0 and( select avg(degree) from score b where a.cno=b.cno ) 34. 查询所有任课教师的Tname和Depart. select tname,depart from teacher where tno in( select tno from course ) 35 . 查询所有未讲课的教师的Tna
while (true) { Console.WriteLine("请输入学生姓名"); string a = Console.ReadLine(); if (a == "q") { Console.WriteLine("结束"); break; } } Console.WriteLine("请输入学生姓名"); string a = Console.ReadLine(); while (a != "q")