SELECT campus,semester, AVG(CountOfStudents)
FROM
(
SELECT semester,year,campus, count(*) as CountOfStudents
FROM regestration
GROUP BY semester, year, campus,student_id
) t
GROUP BY campus,semester
我需要做的是找到每个校区每学期的平均人数
我的表结构是:
表名 -注册
student_id
campus
year
batch
semester
campus
, year
,semester
和batch
这些可以帮助识别唯一记录,其中student_id
可能会重复上面的查询给出错误的答案。