<aside> 💡

Project Overview:

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>


Problem Description:

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.


Solution:

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;


Explanation:

  1. Grouping:
  2. Counting Students:
  3. Filtering:

Example Input and Output:

Input: