Select stustudentid stufirstname stulastname sumCCost TotalC
Select stu.student_id,
stu.first_name,
stu.last_name,
sum(C.Cost) TotalCost
From Course C
inner join Section S
on C.Course_No = S.Course_No
Inner Join Enrollment E
on S.Section_ID = E.Section_ID
Inner Join Student stu
on E.Student_ID = Stu.Student_ID
Group by stu.student_id, stu.first_name, stu.last_name
order by Stu.Student_id
The query without changes should yield 165 students.
how many students have paid more than $3000 in tuition.
What statement do I have to add to change the query so that only students that have more than $3000 tuition are displayed?
Solution
To list only students who paid more than 3000 as tuition:
Select stu.student_id,
stu.first_name,
stu.last_name,
sum(C.Cost) TotalCost
From Course C
inner join Section S
on C.Course_No = S.Course_No
Inner Join Enrollment E
on S.Section_ID = E.Section_ID
Inner Join Student stu
on E.Student_ID = Stu.Student_ID
Group by stu.student_id, stu.first_name, stu.last_name
Having TotalCost > 3000
order by Stu.Student_id

