MySQL以数据库user_db及数据表student、teacher、class、course、sc为基础(11)查询选修“数据库原理”的学生的最高成绩、最低成绩、平均成绩; (12)查询平均成绩在60分以上的课程及其平均成绩; (13)查询平均成绩大于“高莉”的平均成绩的学生学号、姓名及平均成绩; (14)查询每门课程中成绩最低的学生的学号、姓名、性别、院系; (15)查询只被一名学生选修的课程的课程号、课程名。
时间: 2023-06-13 18:07:21 浏览: 142
11.
```
SELECT MAX(score) AS max_score, MIN(score) AS min_score, AVG(score) AS avg_score
FROM sc
WHERE course_name = '数据库原理';
```
12.
```
SELECT course_id, course_name, AVG(score) AS avg_score
FROM sc
GROUP BY course_id, course_name
HAVING AVG(score) > 60;
```
13.
```
SELECT s.stu_id, s.stu_name, AVG(score) AS avg_score
FROM student s, sc c
WHERE s.stu_id = c.stu_id
GROUP BY s.stu_id, s.stu_name
HAVING AVG(score) > (SELECT AVG(score) FROM sc WHERE stu_name = '高莉');
```
14.
```
SELECT s.stu_id, s.stu_name, s.gender, s.department, c.course_name, MIN(score) AS min_score
FROM student s, sc c
WHERE s.stu_id = c.stu_id
AND score = (SELECT MIN(score) FROM sc WHERE course_name = c.course_name)
GROUP BY c.course_name, s.stu_id, s.stu_name, s.gender, s.department;
```
15.
```
SELECT course_id, course_name
FROM sc
GROUP BY course_id, course_name
HAVING COUNT(DISTINCT stu_id) = 1;
```
阅读全文