Add a sum() column in select statement

I have this statement that displays the following fields.

 select distinct sch.school_number, sch.name, cs.course_number, cs.course_name, [PossibleCredits]
 from courses cs 
 inner join schools sch on cs.schoolid = sch.school_number
 inner join sections se on cs.course_number = se.course_number
 order by sch.school_number, cs.course_number 

Now I'd like to get the sum of the num_of_students in each course section. Each record in the sections table has a field called num_of_students and this should be added (by course_number) and displayed as PossibleCredits.

How can I accomplish this? Thanks.

remove the distinct. group by the other fields. and add sum(num_of_students) as PossibleCredits to the select.

1 Like