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
I need to do is to find the average number of people per semester of each campus
My table structure is:
Table name – registration
student_id
campus
year
batch
semester
campus, year, semester and batch these can help identify unique records, where as student_id may repeat itself the query above gives wrong answer.
Follow these steps:
student_IDfrom theGROUP BYclause andDISTINCTinsideCOUNT()query,