SQL


Интересные задачки по SQL, варианты решения мои и те что понравились. Для более детального изучения интересных решений.


596. Classes More Than 5 Students

🔗 Leetcode

My solution:

SELECT t.class AS class
FROM (
    SELECT class, COUNT(DISTINCT student) AS count
    FROM Courses
    GROUP BY class
) AS t
where t.count >= 5;

Other solutions:

with g as (select class, count(student) c from courses group by 1)
select class from g where c > 4
select class from courses group by class having count(*) >= 5


📂 SQL | Последнее изменение: 09.04.2024 16:43