首页 > 其他分享 >10.过滤

10.过滤

时间:2022-12-28 18:11:35浏览次数:38  
标签:10 product GROUP Write 过滤 MySQL id SELECT

182.查找重复的电子邮箱

i.

1 # Write your MySQL query statement below
2 SELECT
3   Email
4 FROM
5   Person
6 GROUP BY Email
7 HAVING COUNT(Email) > 1

ii.哈哈,这个属实是重复了

1 # Write your MySQL query statement below
2 SELECT DISTINCT
3    p1.Email
4 FROM
5    Person p1
6 WHERE
7    p1.Email IN (SELECT p2.Email FROM Person p2 GROUP BY p2.Email HAVING COUNT(p2.Email) > 1)

 

1050.合作过至少三次的演员和导演

i.

1 # Write your MySQL query statement below
2 SELECT
3    actor_id, director_id
4 FROM
5    ActorDirector
6 GROUP BY actor_id, director_id
7 HAVING COUNT(actor_id) >= 3

ii.

1 # Write your MySQL query statement below
2 SELECT 
3     A.actor_id,A.director_id
4 FROM 
5     (SELECT a1.actor_id,a1.director_id,COUNT(a1.actor_id) num
6     FROM ActorDirector a1
7     GROUP BY a1.actor_id,a1.director_id) AS A
8 WHERE
9     A.num >= 3

 

1587.银行账户概要II

i.

1 # Write your MySQL query statement below
2 SELECT
3    Users.name NAME,SUM(Transactions.amount) BALANCE
4 FROM 
5    Users LEFT JOIN Transactions ON Users.account = Transactions.account
6 GROUP BY Users.account
7 HAVING SUM(Transactions.amount) > 10000

ii.

1 # Write your MySQL query statement below
2 SELECT
3     Users.name name, T1.cnt balance
4 FROM
5     Users LEFT JOIN (SELECT account, SUM(amount) cnt
6             FROM Transactions 
7             GROUP BY account) AS T1 ON Users.account = T1.account
8 WHERE
9     T1.cnt > 10000

 

1084.销售分析III

i.

1 # Write your MySQL query statement below
2 SELECT
3    p.product_id,p.product_name 
4 FROM
5    Product p LEFT JOIN Sales s ON p.product_id = s.product_id
6 GROUP BY p.product_id
7 HAVING MIN(sale_date) >= '2019-01-01' 
8 AND MAX(sale_date) <= '2019-03-31'

ii.

 1 # Write your MySQL query statement below
 2 SELECT
 3   product_id, 
 4   product_name
 5 FROM
 6   Product
 7 WHERE
 8   product_id in (SELECT product_id
 9                  FROM Sales
10                  GROUP BY product_id
11                  HAVING SUM(sale_date BETWEEN '2019-01-01' AND '2019-03-31') = COUNT(*))
12 
13   

iii.

1 # Write your MySQL query statement below
2 SELECT p.product_id, p.product_name
3 FROM Product p, Sales s
4 WHERE p.product_id = s.product_id
5 GROUP BY s.product_id
6 HAVING sum(sale_date between '2019-01-01' and '2019.03-31') = count(*)

 

标签:10,product,GROUP,Write,过滤,MySQL,id,SELECT
From: https://www.cnblogs.com/balabalabubalabala/p/16920150.html

相关文章

  • 10.编写自动化测试
    一、如何编写测试测试函数的函数体中一般包含3个部分:准备所需的数据或状态;调用需要测试的代码;断言运行结果与我们所期望的一致;1、测试函数的构成在最简单的情形下,R......
  • P1036 [NOIP2002 普及组] 选数(DFS + 不降原则)
    P1036[NOIP2002普及组]选数题意​ 在n个数里选k个数,有多少中选法,使得选出来的数的和为素数。不能重复选。思路​ n很小,直接爆搜,但是如果不使用不降原则的话,就......
  • win10优化
    文章目录​​1.设置cpu处理器个数为最大​​​​2.设置电源方案为卓越性能​​​​3.设置网速(Qos)​​​​4.禁用win10的某些服务​​​​5.关闭系统防火墙​​​​6......
  • Win10系统如何修改hosts文件
    Win10系统如何修改hosts文件?win10系统在修改hosts文件的时候都遇到了权限不足,而不会像​​XP​​​系统和​​Win7​​系统可以直接修改hosts文件。下面就让我们来看看Win......
  • Oracle like多条件过滤
    模糊匹配多个条件--全模糊匹配whereREGEXP_LIKE(字段名,'(匹配串1|匹配串2|...)')--右模糊匹配whereREGEXP_LIKE(字段名,'^(匹配串1|匹配串2|...)')--左模糊匹配......
  • 1024 我敢送,你敢参与吗?
    喜迎1024大家好,一年一度的1024程序员节,又双叒叕来啦!在这喜大普奔的日子里,祝愿所有的程序员猿媛节日快乐!1024咱们能不能不不不加班~好啦,无需太多前奏,直奔主题。为了感谢......
  • 推荐 10 款 C++ 在线编译器
    1CodingGroundUrl:​https://www.tutorialspoint.com/compile_cpp_online.php​​CodingGround是Tutorialspoint(很强大的免费教程网站)的一个编码平台。它提供的编译器支......
  • 过滤器_有效数据过滤
    需求:模拟:论坛过滤敏感词汇!实现思路:1.Dis.jsp  讨论区页面2.DisServlet.java  处理提交    ---》获取请求参数    ---》......
  • 过滤器_编码统一处理
    问题:处理请求数据中文问题!   【GET/POST】    每个servlet都要做这些操作,把公用的代码抽取-过滤器实现!问题原因:  出现get中文乱码,是......
  • 修改内核源码绕过反调试检测(Android10)
    一、Android反调试     反调试在代码保护中扮演着非常重要的角色,虽然不能完全阻止攻击者,但是能加大攻击者的分析时间成本。目前绝大多数Androidapp都加固了,为了防......