数据查询(二) 1. 查询平均成绩大于70分的学生的学号、姓名、平均分,并按分数由高到低排序。 select student.学号,姓名,avg(成绩) as 平均分 from student,score where student.学号=score.学号 group by student.学号,姓名 having avg(成绩)>70 order by avg(成绩) desc; 2. 查询每位学生所选课程,每门课程的学分及学生所取得的成绩,并降序排列。(显示学号,课程号,学分,成绩) select 学号,course.课程号,学分,成绩 from score,course where course.课程号=score.课程号 order by 成绩 desc; 3. 查找每门课程的选修学生。(显示课程的课程号,学生的学号,姓名及所取得的成绩) select 课程号,student.学号,姓名,成绩 from student,score where student.学号=score.学号 order by 课程号; 4. 查询选修英语课程的学生的学号,姓名,专业并显示成绩。 方法一:select student.学号,姓名,专业,成绩 from student,score where student.学号=score.学号 and 课程号=(select 课程号 from course where 课程名='英语'); 方法二:select student.学号,姓名,专业,成绩 from student,score,course where student.学号=score.学号 and course.课程号=score.课程号 and 课程名='英语'; 5. 查询选课门数大于4门课程的学生的学号及姓名。 select student.学号,姓名 from student,score where student.学号=score.学号 group by student.学号,姓名 having count(课程号)>4; 6. 查询各门课程的平均成绩,结果按平均成绩降序排序 select 课程号,avg(成绩) as 平均成绩 from score group by 课程号 order by avg(成绩) desc; 7. 查询与学号为2009030102的学生在A001课程中得分相同的学生的学号、姓名及成绩。 8. 查询数学成绩最高分的学生的学号,姓名,成绩。 select student.学号,姓名,成绩 from student,score where student.学号=score.学号 and 成绩=(select max(成绩) from score where 课程号=(select 课程号 from course where 课程名='数学')) and 课程号=(select 课程号 from course where 课程名='数学'); 本文来源:https://www.wddqw.com/doc/7329b0b083c4bb4cf6ecd10e.html