sql leetcode -Duplicate Emails

第一种解法:
select distinct p1.Email as Email from Person p1, Person p2 where p1.Email=p2.Email and p1.Id>p2.id;
第二种解法:
select Email from Person group by Email having count(Email)>1;
sql 中有一系列 聚合函数: sum, count, max, avg, 这些函数作用域多条记录上
select sum(population) from b_table;
而通过group by 子句, 可以让sum和 count 这些函数对于属于一组的数据起作用。 计算population,可以指定region
select region, SUM(population),SUM(area)
from b_table
group by region
having 子句可以筛选成组后的数据,where子句在聚合前筛选记录, 也就是作用域group by ,having子句之前,而having 子句对聚合后的记录进行筛选:
select region, sum(population),sum(area)
from b_table
group by region
having sum(population)>100000
不能使用where来筛选超过100000的地区,因为表汇总不存在这样的记录。。。
sql leetcode -Duplicate Emails的更多相关文章
- [LeetCode] Duplicate Emails 重复的邮箱
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...
- LeetCode - Duplicate Emails
Description:Write a SQL query to find all duplicate emails in a table named Person. 找出表中重复的Email. # ...
- LeetCode——Duplicate Emails(使用group by以及having解决分组统计结果)
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...
- [LeetCode] Delete Duplicate Emails 删除重复邮箱
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...
- [SQL]LeetCode182. 查找重复的电子邮箱 | Duplicate Emails
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...
- Leetcode 182. Duplicate Emails
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...
- LeetCode DB: Duplicate Emails
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...
- 【SQL】182. Duplicate Emails
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...
- LeeCode(Database)-Duplicate Emails
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...
随机推荐
- POJ--1056 IMMEDIATE DECODABILITY && POJ--3630 Phone List(字典树)
题目链接 题目大意 看输入的每个字符串中是否有一个字符串是另一个字符串的前缀 #include<iostream> #include<cstring> #include< ...
- 【LOJ#6277】数列分块1
题目大意:维护一个长度为 N 的序列,支持区间修改.单点查询. 代码如下 #include <bits/stdc++.h> using namespace std; const int m ...
- textarea高度自适应自动展开
在使用之前,推荐两个比较好的事件,分别是oninput和onpropertychange,IE9以下不兼容oninput.在textarea发生变化时,可以通过监听这两个事件来触发你需要的功能. te ...
- python3+django2 开发易语言网络验证(下)
第六步:网络验证服务器端项目上线部署 功夫不负有心人,终于部署成功啦! 前期准备: 项目名:netauth 系统:百度云服务器下的Ubuntu16.4 软件:xshell(无论如何想办法用这个跟服务器 ...
- tensorflow中tf.ConfigProto()用法解释
在看C3D代码的时候,看见有一段代码是 config = tf.ConfigProto()#主要是配置tf.Session的运行方式,GPU还是CPU,在这里选择的是GPU的运行方式 config.g ...
- HDU - 5952 Counting Cliques(DFS)
A clique is a complete graph, in which there is an edge between every pair of the vertices. Given a ...
- 让mysql监听ipv4
系统:centos7 关闭ipv6方法: 方法1:编辑/etc/sysctl.conf文件,添加如下两行到文件 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6. ...
- opencv: 轮廓提取;
一般轮廓提取是通过对图像的梯度进行卷积计算,得到图像边缘(滤波),常用的边缘检测方法有candy.sobel. Laplacian等,再对二值化后的边缘图像进行轮廓计算: 1.Candy算子: cv: ...
- C函数调用
目录 C函数调用 设置SP SP分析 区分NAND和NOR启动 参数调用 title: C函数调用 tags: ARM date: 2018-10-14 16:37:10 --- C函数调用 设置SP ...
- perl trick
一.die if以及文件的操作 #!/usr/bin/perl -w use strict; die "USAGE:\n\tperl $0 <><><>\ ...