[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 ...
随机推荐
- go 的正则表达式
go 操作字符串.由于 go 中的字符串不是对象,所以没有直接操作字符串的相关方法.要操作字符串可以使用 strings 包或者 regexp 包处理. 一.简要介绍一下,strings 包 (str ...
- FIFO设计中的深度计算【zz】
FIFO设计中的深度计算: 写时钟频率 w_clk, 读时钟频率 r_clk, 写时钟周期里,每B个时钟周期会有A个数据写入FIFO: 读时钟周期里,每Y个时钟周期会有X个数据读出FIFO: 则,FI ...
- 二进制安装mysql
1.1 MySQL安装介绍 mysql软件下载地址信息: www.mysql.com mirrors.sohu.com mysql软件下载完毕后,查看mysql解压后目录文件大小 1.下载解压my ...
- ADT下载地址(申明:来源于网络)
ADT下载地址(含各版本),最新ADT-23.0.6(申明:来源于网络) 地址:http://write.blog.csdn.net/mdeditor
- Zabbix使用grafana展示图形
系统环境查看 官网下载grafana wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.0.1-1. ...
- db2 tablespaces table bufferpools reorgs
通过快照查看表空间 表 缓冲池信息 db2 get snapshot for tablespaces on teps > tablespace.infodb2 get snapshot for ...
- iPhone XS 能否经受的起寒冬的考验
我的知乎文章链接: https://zhuanlan.zhihu.com/p/51782644 华北地区近日寒风凛冽,温度骤降,已经进入真正的冬天了,最低温度可以达到零下10度,我们手里的iPhone ...
- 树剖||树链剖分||线段树||BZOJ4034||Luogu3178||[HAOI2015]树上操作
题面:P3178 [HAOI2015]树上操作 好像其他人都嫌这道题太容易了懒得讲,好吧那我讲. 题解:第一个操作和第二个操作本质上是一样的,所以可以合并.唯一值得讲的点就是:第二个操作要求把某个节点 ...
- MySQL之多表查询一 介绍 二 多表连接查询 三 符合条件连接查询 四 子查询 五 综合练习
MySQL之多表查询 阅读目录 一 介绍 二 多表连接查询 三 符合条件连接查询 四 子查询 五 综合练习 一 介绍 本节主题 多表连接查询 复合条件连接查询 子查询 首先说一下,我们写项目一般都会建 ...
- LightOJ 1224 - DNA Prefix - [字典树上DFS]
题目链接:https://cn.vjudge.net/problem/LightOJ-1224 Given a set of $n$ DNA samples, where each sample is ...