<aside> 💡
This project demonstrates the ability to aggregate and analyze relational database records. The objective was to identify all classes with a minimum of five enrolled students, helping stakeholders evaluate class popularity and capacity.
</aside>
The Courses table contains the following information:
The combination of student and class forms the primary key, ensuring that each record is unique and no student can be enrolled in the same class more than once.
The task was to identify all classes with at least five enrolled students and return the results in any order.
The query groups data by classes and uses an aggregate function to count the number of students in each class. Classes with at least five students are returned.
SELECT c.class
FROM Courses c
GROUP BY c.class
HAVING COUNT(c.student) >= 5;
GROUP BY c.class aggregates the records by class, allowing us to calculate metrics like the number of students per class.COUNT(c.student) counts the number of unique students enrolled in each class.HAVING COUNT(c.student) >= 5 ensures only classes with five or more students are included in the output.