数据库系统原理---3-2要素.ppt

数据库系统原理---3-2要素

SQL查询语句补充例子: 例一:查询最高分的学生学号和课程号。  select s#,c#,Max(grade) from sc 例二:查询至少有5名学生选修的并且以3开头的课程号的平均分。  select c#,avg(grade) from sc where c# like ‘3%’ group by c# having count(*)5; 例三:查询选修“3-105”课程的成绩高于“109”号同学成绩的所有同学的记录。  select x.c#,x.s#,x.grade from sc x,sc y where x.c#=‘3-105’ and x.gradey.grade and y.s#=‘109’ and y.c#=’3-105’; 例四:查询选修某门课程的同学人数小于15人的教师姓名。(设C表扩展为:C# CNAME PC# PT )  select pt from c where c# in(select y.c# from c x,sc y where x.c#=y.c# group by y.c# having count(y.c#)15); 例五:查询选修了编号为“3-105”且成绩高于选修编号为“3-245”课程的同学学号。  select s# from sc where c#=‘3-105’ and gradeall (select gra

文档评论(0)

1亿VIP精品文档

相关文档