Leetcode Problem 596. Classes More Than 5 Students

596. Classes More Than 5 Students

Leetcode Solutions

Using GROUP BY and HAVING to Find Classes with at Least Five Students

  1. Use the GROUP BY clause to aggregate the records by the class column.
  2. Use the COUNT function to count the number of students in each class.
  3. Use the HAVING clause to filter the results to only include classes that have a count of students greater than or equal to five.
  4. Select the class column from the filtered results to get the final output.
erDiagram
    Courses {
        varchar student
        varchar class
        student class PK
    }

Using Sub-query and WHERE Clause to Find Classes with at Least Five Students

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...