SQL Query to Find Average Degree for Courses with at Least 3 Students and Starting with '3'
The given SQL query retrieves the average degree for each course (cno) that meets the following conditions:
- The course (cno) must have at least three students enrolled in it.
- The course (cno) must start with the digit '3'.
Here is the formatted SQL query:
SELECT AVG(degree)
FROM score
WHERE cno IN (
SELECT cno
FROM score
GROUP BY cno
HAVING COUNT(1) >= 3
)
AND cno LIKE '3%'
GROUP BY cno;
AI 优化版
原文地址:https://www.cveoy.top/t/topic/qhWT 著作权归作者所有。请勿转载和采集!