Auto commit

This commit is contained in:
2025-02-25 09:51:43 +08:00
parent 10a4acf101
commit d44aeed220
+25 -1
View File
@@ -332,9 +332,33 @@ FROM scores sc, students st
WHERE sc.course_id = '01' AND sc.score < 60 AND sc.student_id = st.id
ORDER BY sc.score DESC;
#13.
#13.
SELECT c.`name`, AVG(sc.score)
FROM scores sc, courses c
WHERE sc.course_id = c.id
GROUP BY c.id
ORDER BY AVG(sc.score) DESC;
#14. ID name>=6070-8080-90>=90
SELECT c.id '课程ID', c.`name` '课程名称', MAX(s.score) '最高分', MIN(s.score) '最低分', ROUND(AVG(s.score), 1) '平均值'
FROM scores s, courses c
WHERE s.course_id = c.id
GROUP BY c.id;
SELECT s.course_id,
CONCAT(TRUNCATE(COUNT(IF(s.score >=60, TRUE, NULL))/sc.count*100,2), '%') s1,
CONCAT(TRUNCATE(COUNT(IF(s.score >=70 AND s.score < 80, TRUE, NULL))/sc.count*100,2), '%') s2,
CONCAT(TRUNCATE(COUNT(IF(s.score >=80 AND s.score < 90, TRUE, NULL))/sc.count*100,2), '%') s3,
CONCAT(TRUNCATE(COUNT(IF(s.score >=90, TRUE, NULL))/sc.count*100,2), '%') s4
FROM scores s, (
SELECT course_id, COUNT(*) count
FROM scores
GROUP BY course_id
) sc
WHERE s.course_id = sc.course_id
GROUP BY s.course_id;
#15. Score