From 2087cbe56d343182e3f9e3a189fea0b4ca4977d7 Mon Sep 17 00:00:00 2001 From: ivanbyone Date: Sun, 29 Jun 2025 13:27:18 +0300 Subject: [PATCH] task: #596 --- README.md | 1 + .../596. Classes With at Least 5 Students.sql | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 leetcode/easy/596. Classes With at Least 5 Students.sql diff --git a/README.md b/README.md index 8780dba..ace1e99 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Have a good contributing! - [577. Employee Bonus](./leetcode/easy/577.%20Employee%20Bonus.sql) - [586. Customer Placing the Largest Number of Orders](./leetcode/easy/586.%20Customer%20Placing%20the%20Largest%20Number%20of%20Orders.sql) - [595. Big Countries](./leetcode/easy/595.%20Big%20Countries.sql) + - [596. Classes With at Least 5 Students](./leetcode/easy/596.%20Classes%20With%20at%20Least%205%20Students.sql) 2. [Medium](./leetcode/medium/) - [176. Second Highest Salary](./leetcode/medium/176.%20Second%20Highest%20Salary.sql) diff --git a/leetcode/easy/596. Classes With at Least 5 Students.sql b/leetcode/easy/596. Classes With at Least 5 Students.sql new file mode 100644 index 0000000..5deee80 --- /dev/null +++ b/leetcode/easy/596. Classes With at Least 5 Students.sql @@ -0,0 +1,25 @@ +/* +Question 596. Classes With at Least 5 Students +Link: https://leetcode.com/problems/classes-with-at-least-5-students/description/ + +Table: Courses + ++-------------+---------+ +| Column Name | Type | ++-------------+---------+ +| student | varchar | +| class | varchar | ++-------------+---------+ +(student, class) is the primary key (combination of columns with unique values) for this table. +Each row of this table indicates the name of a student and the class in which they are enrolled. + + +Write a solution to find all the classes that have at least five students. + +Return the result table in any order. +*/ + +SELECT class +FROM Courses +GROUP BY class +HAVING COUNT(1) >= 5