✅Easiest Basic SQL Solution | 3 Approaches | With Explanation🏆
\n\n#Approach 1 : Basic Group by\nSELECT class \nFROM Courses \nGROUP BY class\nHAVING  COUNT(student)>=5;\n\nExplanation:\n This approach first groups the rows
\n```\n#Approach 1 : Basic Group by\nSELECT class \nFROM Courses \nGROUP BY class\nHAVING  COUNT(student)>=5;\n```\n**Explanation:**\n* This approach first groups the rows of the Courses table by the class column using the GROUP BY clause.\n* Then, it filters the groups using the HAVING clause to include only those classes where the count of students (COUNT(student)) is greater than or equal to 5.\n* Finally, it selects the class names that meet this condition.\n\n```\n#Approach 2 : SubQuery\nSELECT DISTINCT class \nFROM Courses \nWHERE (\n    SELECT COUNT(*) \n    FROM Courses AS c \n    WHERE c.class = Courses.class\n) >= 5;\n```\n**Explanation:**\n\n* This approach employs a subquery to calculate the count of students for each class.\n* The outer query selects distinct class names from the Courses table.\n* The subquery counts the number of occurrences of each class in the Courses table and compares it to 5.\n* It selects only those classes where the count of students is greater than or equal to 5.\n\n\n```\n#Approach 3 : Join\nSELECT DISTINCT c1.class\nFROM Courses c1\nJOIN (\n    SELECT class\n    FROM Courses\n    GROUP BY class\n    HAVING COUNT(student) >= 5\n) AS class_counts\nON c1.class = class_counts.class;\n```\n**Explanation:**\n\n* This approach first calculates the count of students for each class using a subquery with GROUP BY and HAVING.\n* It then performs an inner join between the Courses table (aliased as c1) and the subquery result (aliased as class_counts) on the class column.\n* Finally, it selects distinct class names from the resulting datase
['MySQL']