LeetCode - 596. Classes More Than 5 Students
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的更多相关文章
- LeetCode 596. Classes More Than 5 Students (超过5名学生的课)
题目标签: 题目给了我们 courses 表格,让我们找到 一个有至少5名学生的班级. 利用group by 把班级分类,在用Having count 来判断是否有5名,注意这里还需要用 distin ...
- [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 ...
- 596. Classes More Than 5 Students
There is a table courses with columns: student and class Please list out all classes which have more ...
- [SQL]LeetCode596. 超过5名学生的课 | Classes More Than 5 Students
SQL架构 Create table If Not Exists courses (student varchar(), )) Truncate table courses insert into c ...
- leetcode 596 BUG笔记
There is a table courses with columns: student and class Please list out all classes which have more ...
- All LeetCode Questions List 题目汇总
All LeetCode Questions List(Part of Answers, still updating) 题目汇总及部分答案(持续更新中) Leetcode problems clas ...
- Leetcode中的SQL题目练习(一)
595. Big Countries https://leetcode.com/problems/big-countries/description/ Description name contine ...
- [LeetCode] All questions numbers conclusion 所有题目题号
Note: 后面数字n表明刷的第n + 1遍, 如果题目有**, 表明有待总结 Conclusion questions: [LeetCode] questions conclustion_BFS, ...
- SQL练习——LeetCode解题和总结(1)
只用于个人的学习和总结. 178. Rank Scores 一.表信息 二.题目信息 对上表中的成绩由高到低排序,并列出排名.当两个人获得相同分数时,取并列名次,且名词中无断档. Write a SQ ...
随机推荐
- Unity Object Pool完全体
using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; public ...
- JVM GC杂谈之理论入门
GC杂谈之理论入门 JVM堆布局介绍 JVM堆被划分成两个不同的区域:新生代 ( Young ).老年代 ( Old ).新生代 ( Young ) 又被划分为三个区域:Eden.From Sur ...
- thinkphp 中concat(连接)使用方法
1.concat将title和id连接作为truename新的字段,left从url字段左侧开始截取25个字符,同理right也可. 2.getLastql用法:
- webzip怎么用 如何用webzip下载整个网站?
相信很多站长对webzip这款软件都并不感到陌生,它功能强大,能够完整下载网站的内容,或者你也可以选择自行设置下载的层数.文件类型.网页与媒体文件的定位等等.具体详情你可以在百度上去搜一下.由于web ...
- 【Android】版本的名称
http://www.cnblogs.com/imlucky/archive/2011/10/21/2220596.html
- 量化投资与Python之pandas
pandas:数据分析 pandas是一个强大的Python数据分析的工具包.pandas是基于NumPy构建的. pandas的主要功能具备对其功能的数据结构DataFrame.Series集成时间 ...
- Spring Cloud Zuul网关 Filter、熔断、重试、高可用的使用方式。
时间过的很快,写springcloud(十):服务网关zuul初级篇还在半年前,现在已经是2018年了,我们继续探讨Zuul更高级的使用方式. 上篇文章主要介绍了Zuul网关使用模式,以及自动转发机制 ...
- Java的NIO
1. 基本 概念 IO 是主存和外部设备 ( 硬盘.终端和网络等 ) 拷贝数据的过程. IO 是操作系统的底层功能实现,底层通过 I/O 指令进行完成. 所有语言运行时系统提供执行 I/O 较高级 ...
- SCOPE_IDENTITY()
@@IDENTYITY,SCOPE_IDENTITY的主要区别:在有触发器中而且触发器的内容里面含有插入标识符的操作的时候,@@IDENTITY则返回的是触发器里面新插入标识符的值而SCOPE_IDE ...
- 汉诺塔python3函数编写和过程分析
!/usr/bin/env python3 -- coding: utf-8 -- 利用递归函数计算阶乘 N! = 1 * 2 * 3 * ... * N def fact(n): if n == 1 ...