August 9, 2012 at 11:13 am
I need to display the number of courses that have more than 20 persons enrolled, the total number of students in those courses, and the average enrollment per course.
here is the structure for the course table:
CREATE TABLE Course
(Course_ID CHAR(2),
Ref_Number CHAR(5),
Faculty_ID VARCHAR(2),
Term Char(1),
Enrollment INTEGER,
TotRev FLOAT );
And here is my code that I have:
/* CODE
Select Count() As totalCourses , Sum(Enrollment) AS 'TotalStudents', Avg(enrollment)
AS 'AvgEnrollment'
From course
Where Enrollment > 20
Group by course_ID
CODE */
August 9, 2012 at 11:15 am
looks like a homework assignment. You should read the textbook and do the labs. :-P:-P
The probability of survival is inversely proportional to the angle of arrival.
August 9, 2012 at 11:25 am
Not homework!! This is however me studying for my exam. Just tying to make sure I get them right and any help I may need, if your not interested keep scrolling.
August 9, 2012 at 11:27 am
I'll offer a piece of advice, though, in relation to your code.
SELECT Count() AS totalCourses,
Sum(enrollment) AS 'TotalStudents',
Avg(enrollment) AS 'AvgEnrollment'
FROM course
WHERE enrollment > 20
GROUP BY course_id
totalCourses WILL give you the count of courses where enrollment is greater than 20
TotalStudents WILL give you the sum of the students in the data set where enrollment is greater than 20
AvgEnrollment will ONLY give you the average enrollment for the data set where enrollment is greater than 20 (which may or may not be what you're looking for according to the way you've stated your question.)
Erin
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply