SQL查询大全

时间:2016-12-18 14:40:39
【文件属性】:
文件名称:SQL查询大全
文件大小:158KB
文件格式:DOC
更新时间:2016-12-18 14:40:39
Sql查询 答案: 法1:select * from sc where 课程号='3-105' and 成绩 between 60 and80; 法2:select * from sc where 课程号='3-105' and 成绩 > 60 and 成绩 < 80; 2.查询成绩为85、86或88的记录。 注释:用于制定某个集合使用 in 关键字,也可以使用 or 连接符; 答案: 法1:select * from sc where 成绩=85 or 成绩=86or 成绩=88; 法2:select *from sc where 成绩 in(85,86,88); 3.查询'95031'班的学生人数。 注释:count(*)用于计算结果总数; 答案: select count(班级) as 学生人数 from student where 班级='95031'; 4.查询最低分大于70,且最高分小于90的学号列。 注释:having后面跟聚合函数:avg,min,max,count;having语句只能跟在:group by语句后面; 答案: select 学号,min(成绩)as 最低分,max(成绩)as 最高分 from sc groupby 学号 having min(成绩)>70 and max(成绩) < 90; 5.查询至少有5名学生选修并以3开头的课程的平均成绩。 注释:group by 语句置于where语句后面表示根据什么条件来分组; 答案:

网友评论