当前位置:网站首页>【LeetCode数据库1050】合作过至少三次的演员和导演(简单题)
【LeetCode数据库1050】合作过至少三次的演员和导演(简单题)
2022-07-26 08:47:00 【山顶夕景】
一、题目

二、代码
- 因为是要演员和导演合作的 也就是
actor_id和director_id必须都相同才满足条件 所以要加两个分组条件进行groupby。 因为如果分组条件不加director_id那么COUNT(*)计数的是该演员和所有导演的合作次数 而不是和各个导演的合作次数 在测试的第四个例子就会出错。 - 用GROUP BY分组后可以用
HAVING取出想要的组。SQL在使用HAVING子句时 SELECT 语句的顺序为:FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY。
# Write your MySQL query statement below
SELECT actor_id, director_id
FROM ActorDirector
GROUP BY actor_id, director_id
HAVING COUNT(*) >= 3;
边栏推荐
- Alphabetic string
- at、crontab
- OA项目之我的会议(查询)
- SSH,NFS,FTP
- Media at home and abroad publicize that we should strictly grasp the content
- IC's first global hacking bonus is up to US $6million, helping developers venture into web 3!
- Registration of finite element learning knowledge points
- day06 作业--增删改查
- Pan micro e-cology8 foreground SQL injection POC
- [database] gbase 8A MPP cluster v95 installation and uninstall
猜你喜欢

Okaleido上线聚变Mining模式,OKA通证当下产出的唯一方式

KV database based on raft consensus protocol

uni-app 简易商城制作

Set of pl/sql -2

Sklearn machine learning foundation (linear regression, under fitting, over fitting, ridge regression, model loading and saving)

海内外媒体宣发自媒体发稿要严格把握内容关

Maximum common substring & regularity problem

Set of pl/sql

Grid segmentation

Transfer guide printing system based on C language design
随机推荐
Study notes of automatic control principle --- stability analysis of control system
day06 作业--技能题6
IC's first global hacking bonus is up to US $6million, helping developers venture into web 3!
CIS 2020 - alternative skills against cloud WAF (pyn3rd)
【数据库 】GBase 8a MPP Cluster V95 安装和卸载
六、品达通用权限系统__pd-tools-log
[C language] programmer's basic skill method - "creation and destruction of function stack frames"
Mysql8 one master one slave +mycat2 read write separation
OA项目之我的会议(查询)
Registration of finite element learning knowledge points
Oracle 19C OCP certification examination software list
Kotlin properties and fields
内存管理-动态分区分配方式模拟
day06 作业--技能题1
SSH,NFS,FTP
pl/sql之集合
Oracle 19C OCP 1z0-082 certification examination question bank (13-18)
Super potential public chain dfinity -- the best time for DFI developers to enter
Dynamic SQL and exceptions of pl/sql
Pxe原理和概念