There is a table courses with columns: student and class

Please list out all classes which have more than or equal to 5 students.

For example, the table:

+---------+------------+
| student | class |
+---------+------------+
| A | Math |
| B | English |
| C | Math |
| D | Biology |
| E | Math |
| F | Computer |
| G | Math |
| H | Math |
| I | Math |
+---------+------------+

Should output:

+---------+
| class |
+---------+
| Math |
+---------+
# Write your MySQL query statement below
select courses_cnt.class from (select count(DISTINCT student)as cnt,class from courses where 1=1 group by class) as courses_cnt where courses_cnt.cnt >= 5

LeetCode - 596. Classes More Than 5 Students的更多相关文章

  1. LeetCode 596. Classes More Than 5 Students (超过5名学生的课)

    题目标签: 题目给了我们 courses 表格,让我们找到 一个有至少5名学生的班级. 利用group by 把班级分类,在用Having count 来判断是否有5名,注意这里还需要用 distin ...

  2. [LeetCode] 596. Classes More Than 5 Students_Easy tag:SQL

    There is a table courses with columns: student and class Please list out all classes which have more ...

  3. 596. Classes More Than 5 Students

    There is a table courses with columns: student and class Please list out all classes which have more ...

  4. [SQL]LeetCode596. 超过5名学生的课 | Classes More Than 5 Students

    SQL架构 Create table If Not Exists courses (student varchar(), )) Truncate table courses insert into c ...

  5. leetcode 596 BUG笔记

    There is a table courses with columns: student and class Please list out all classes which have more ...

  6. All LeetCode Questions List 题目汇总

    All LeetCode Questions List(Part of Answers, still updating) 题目汇总及部分答案(持续更新中) Leetcode problems clas ...

  7. Leetcode中的SQL题目练习(一)

    595. Big Countries https://leetcode.com/problems/big-countries/description/ Description name contine ...

  8. [LeetCode] All questions numbers conclusion 所有题目题号

    Note: 后面数字n表明刷的第n + 1遍, 如果题目有**, 表明有待总结 Conclusion questions: [LeetCode] questions conclustion_BFS, ...

  9. SQL练习——LeetCode解题和总结(1)

    只用于个人的学习和总结. 178. Rank Scores 一.表信息 二.题目信息 对上表中的成绩由高到低排序,并列出排名.当两个人获得相同分数时,取并列名次,且名词中无断档. Write a SQ ...

随机推荐

  1. 从零开始学习前端JAVASCRIPT — 4、JavaScript基础Math和Date对象的介绍

    Math对象的介绍 1:Math对象 Math 对象用于执行数学任务.并不像 Date 和 String 那样是对象的类,因此没有构造函数 Math().您无需创建它,通过把 Math 作为对象使用就 ...

  2. EntityFramework默认映射规则

    我不太习惯通过CodeFirst去维护数据库(尽管这是未来实现自动编程的必经之路),还是喜欢通过数据库设计工具如PowerDesigner去建表.如果不想对EF的实体和数据表做什么映射的话,就要注意默 ...

  3. 织梦CMS提示DedeTag Engine Create File False错误的解决办法总结

    今天帮客户升级站点,遇到了一个老问题,生成栏目的时候提示"DedeTag Engine Create File False",突然发觉这个问题竟然在以前做站的时候困扰过我多次,于是 ...

  4. putty怎么用?如何使用Putty远程管理Linux主机

    Putty是一个免费的Windows 32平台下用于telnet.rlogin和ssh客户端的远程客户端工具,可以通过PUTTY快速的实现SSH连接linux等主机,下面小编就给大家演示一下如何使用P ...

  5. Java读书推荐

    想要深入掌握一门技术,读书是必不可少的一步,也是最重要的一步.有些书需要读很多遍才能深入理解,经过几本甚至几十本书的熏陶,才能让你在这个行业中越走越远,爱上这个行业,抽出时间多读本书吧,读书会让人如虎 ...

  6. Reflection and array

    java.lang.Reflect.Array类提供了动态创建和访问数组元素的各种静态方法. package com.sunchao.reflection; import java.lang.refl ...

  7. Java中的SerialVersionUID

    Java中的SerialVersionUID 序列化及SergalVersionUID困扰着许多Java开发人员.我经常会看到这样的问题,什么是SerialVersionUID,如果实现了Serial ...

  8. java基础学习总结——java读取properties文件总结

    摘录自:http://www.cnblogs.com/xdp-gacl/p/3640211.html 一.java读取properties文件总结 在java项目中,操作properties文件是经常 ...

  9. what is yaml ?

    what is yaml  ? when I fist time meeting it  is in java projects she as a system config file to my e ...

  10. hash类型

    redis的hash是一个string的key与value的映射表.适合存储对象,与string的类型相比,可以节省内存,并且方便获取整个对象 hset  设置hash field的指定值.不存在则先 ...