[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 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.
Code #用distinct是因为有可能有学生多次选了该门课
SELECT class FROM courses GROUP BY class HAVING COUNT(DISTINCT student) >= 5
[LeetCode] 596. Classes More Than 5 Students_Easy tag:SQL的更多相关文章
- 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 ...
- [LeetCode] 613. Shortest Distance in a Line_Easy tag: SQL
Table point holds the x coordinate of some points on x-axis in a plane, which are all integers. Writ ...
- [LeetCode] 33. Search in Rotated Sorted Array_Medium tag: Binary Search
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e. ...
- [LeetCode] 364. Nested List Weight Sum II_Medium tag:DFS
Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...
- [LeetCode] 849. Maximize Distance to Closest Person_Easy tag: BFS
In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is emp ...
- [LeetCode] 298. Binary Tree Longest Consecutive Sequence_Medium tag: DFS recursive
Given a binary tree, find the length of the longest consecutive sequence path. The path refers to an ...
- [LeetCode] 787. Cheapest Flights Within K Stops_Medium tag: Dynamic Programming, BFS, Heap
There are n cities connected by m flights. Each fight starts from city u and arrives at v with a pri ...
- [LeetCode] 821. Shortest Distance to a Character_Easy tag: BFS
Given a string S and a character C, return an array of integers representing the shortest distance f ...
随机推荐
- linux下安装svn出现configure: error: We require OpenSSL; try --with-openssl
linux下安装svn出现configure: error: We require OpenSSL; try --with-openssl http://blog.csdn.net/woshixion ...
- css学习_css三大特性
css三大特性 1.层叠性(就近原则) 2.继承性(和文字有关的会继承) 3.优先级 (权重问题) 权重:0,0,0,0 0001 ---标签选择器(注意:即使有20个标签选择器也不会比一个伪类选 ...
- Navicat工具、pymysql模块 sql注入
cls超 Navicat工具.pymysql模块 阅读目录 一 IDE工具介绍 二 pymysql模块 一 IDE工具介绍(Navicat) 生产环境还是推荐使用mysql命令行,但为了方便我们测试, ...
- [No0000C4]TortoiseSVN配置外部对比工具
TortoiseSVN -> Settings Diff Viewer : 选中External->找到外部工具:如BCompare.路径如果有空格的最好用"双引号"括 ...
- shell脚本之使用sed和awk进行文本处理
Shell这种脚本语言特点是,结果松散,场景复杂,针对于一些参数都有特殊意义.针对于大部分工程师而言,使用中的情况是你可能会经常忘记参数或其意义,使你不得不查阅man或网上寻求帮助.此篇文档作用就是在 ...
- java设计模式--单例
GOF23(group of four)---由4个大牛总结的JAVA23种常用的设计模式,归根结底都是为了代码的可扩展性. 设计模式中一种比较重要的思想就是:开闭原则,尽量做到对扩展开放,对修改关闭 ...
- 【未完待续】API接口
1.json传输 2.安全:权限 http://blog.csdn.net/linlzk/article/details/50748580. 比如:调用端有userId.psw.version.ti ...
- 虚拟机VirtualBox与CentOS 7安装
一.VirtualBox 我们电脑的操作系统一般都是Windows,如果我们要学习Linux,那么可以在我们的电脑上装个虚拟机,然后在这虚拟机上安装Linux.虚拟机可以用VirtualBox 或者 ...
- 浏览器的兼容性(CSS浏览器兼容性、CSS hack)
一.关于CSS hack(尽量不用或者少用,减少页面复杂度) 1.条件注释法:(我的测试是IE9及其以下才有效) 这种方式是IE浏览器专有的Hack方式,微软官方推荐使用的hack方式.举例如下 只在 ...
- linux 查看系统资源使用情况:vmstat
vmstat命令可以动态地查看系统资源的使用情况,如内存/交换分区/CPU的使用情况,通过使用该命令可以判断系统的瓶颈在哪里: [root@mysql ~]# vmstat procs ------- ...