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. Node.js系列-http

    前言: 最近一直忙着公司项目的事,战友们的留言也没空回复,博客也有段时间没有更新了,年底了就是一个的忙啊~~~(ps:同感的也给个赞吧) 现在前端的就是一直地更新一直有新的东西出来,什么ES2015, ...

  2. Linux chmod命令及权限含义

    对于一条权限赋值命令:sudo chmod  -R 764 ×××:我们必须了解其含义: (1)各字段含义:sudo chmod  -R(更改文件夹及其子文件夹)                    ...

  3. linux一键安装

    http://source.docs.cloudcare.cn/support/faq/webfaq/webfaq_11/?spm=5176.730006-cmgj000262.102.8.QsmPR ...

  4. sublime text3怎么批量查找替换文件夹中的字符

    在编写代码的时候,往往有些代码是重复的,但是如果要改一处代码,其他的地方也要改.那么怎么批量修改呢?下面小编就以sublime text3为例来讲解一下sublime text3怎么批量查找替换文件夹 ...

  5. [SinGuLaRiTy] 复习模板-搜索

    [SinGuLaRiTy-1043] Copyright (c) SinGuLaRiTy 2017. All Rights Reserved. 桶排序 void bucketSort(int a[], ...

  6. log4j:ERROR Category option " 1 " not a decimal integer.错误解决

    log4j.properties 的配置文件中: log4j.appender.stdout.layout.ConversionPattern =  %d{ABSOLUTE} %5p %c{ 1 }: ...

  7. Java高级工程师——面试总结

    面试技巧 1.背熟你的简历 原因:面试的第一个问题,一般都是让你简单介绍下你自己,或者介绍一下你最近的项目,而一个面试者,如果连自己的简历都无法熟知,对里面提到的项目.技术都无法描述清楚的话,我想没有 ...

  8. 通过psping测试结果,初步判断远端服务器的状态

    1.psping的输出结果为如下正常显示时,说明远端服务器的IP及端口可用 C:\Users\he.liming>psping 139.219.66.205:4352 PsPing v2.10 ...

  9. Servlet--HttpUtils类

    定义 public class HttpUtils 收集 HTTP Servlet 使用的静态的有效的方法. 方法 1.getRequestURL public static StringBuffer ...

  10. LINUX读写文件区别

    body, table{font-family: 微软雅黑; font-size: 10pt} table{border-collapse: collapse; border: solid gray; ...