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 |
+---------+
Note:
The students should not be counted duplicate in each course.
请列出所有超过或等于5名学生的课程。
可能会有重复行
MySQL(2707ms):
# Write your MySQL query statement below
SELECT class
FROM courses
GROUP BY class
HAVING COUNT(DISTINCT student) >= 5 ;
596. Classes More Than 5 Students的更多相关文章
- 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 ...
- LeetCode 596. Classes More Than 5 Students (超过5名学生的课)
题目标签: 题目给了我们 courses 表格,让我们找到 一个有至少5名学生的班级. 利用group by 把班级分类,在用Having count 来判断是否有5名,注意这里还需要用 distin ...
- [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. 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 ...
- All LeetCode Questions List 题目汇总
All LeetCode Questions List(Part of Answers, still updating) 题目汇总及部分答案(持续更新中) Leetcode problems clas ...
- SQL练习——LeetCode解题和总结(1)
只用于个人的学习和总结. 178. Rank Scores 一.表信息 二.题目信息 对上表中的成绩由高到低排序,并列出排名.当两个人获得相同分数时,取并列名次,且名词中无断档. Write a SQ ...
- Leetcode中的SQL题目练习(一)
595. Big Countries https://leetcode.com/problems/big-countries/description/ Description name contine ...
- Swift LeetCode 目录 | Catalog
请点击页面左上角 -> Fork me on Github 或直接访问本项目Github地址:LeetCode Solution by Swift 说明:题目中含有$符号则为付费题目. 如 ...
- 【sql】leetcode习题 (共 42 题)
[175]Combine Two Tables (2018年11月23日,开始集中review基础) Table: Person +-------------+---------+ | Column ...
随机推荐
- JavaScript定义类的方式与其它OO语言有些差异
JavaScript面向对象的程序编写与其它OO语言有一些出入,所以使用JavaScript的面向对象特性的时候,需要注意一些规范性的问题.下面就简单地谈一下,JavaScript如何定义一个类,在定 ...
- c++ string写时复制
string写时复制:将字符串str1赋值给str2后,除非str1的内容已经被改变,否则str2和str1共享内存.当str1被修改之后,stl才为str2开辟内存空间,并初始化. #include ...
- bzoj 2095 [Poi2010]Bridges 判断欧拉维护,最大流+二分
[Poi2010]Bridges Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 1448 Solved: 510[Submit][Status][D ...
- [技巧篇]13.从今天开始做一个有理想的人,放弃alter的调试,拥抱console.log
在js前端开发时,为了调试经常会加上 console.log.但是在有的浏览器(比如IE)中会报错,怎么办呢?好像10之后也开始支持了!如果以防方一,可以使用如下方式 在js文件最前面添加如下js代码 ...
- UVA 12716 GCD XOR
https://vjudge.net/problem/UVA-12716 求有多少对整数(a,b)满足:1<=b<=a<=n,且gcd(a,b)=a XOR b 结论:若gcd(a, ...
- uva 1506 Largest Rectangle in a Histogram
Largest Rectangle in a Histogram http://acm.hdu.edu.cn/showproblem.php?pid=1506 Time Limit: 2000/100 ...
- Bzoj2832 / Bzoj3874 宅男小C
Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 124 Solved: 26 Description 众所周知,小C是个宅男,所以他的每天的食物要靠外 ...
- Codeforces Round #478 (Div. 2)
题目链接:http://codeforces.com/contest/975 A. Aramic script time limit per test:1 second memory limit pe ...
- ribbon设置url级别的超时时间
序 ribbon的超时设置,只能按转发的serviceId来分的,无法像nginx那样直接在每个转发的链接里头设置超时时间.这里hack一下,实现url基本的ribbon超时时间设置.具体的思路就是重 ...
- 从零开始PHP攻略(001)——Bob的汽车零部件商店
1.创建订单表单 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> < ...