思路:

两种思路,可以给当成两个表也可以给当成一张表来做

group by就是按照某个属性给表分个组,然后having语句的含义是“对于每一个group”怎么怎么样

补充知识:count(column),count(distinct column),count(*)的区别

对于符合条件(通过where或者group by+having选出来)的一系列的元组,count(*)的作用是计算出他们所有的行数

而count(col)的作用是对于选出所有元组的col这一列不为NULL的行数

而count(distinct col)有了上面的基础就会比较好理解,就是所有元组的col这一列不为NULL而且不重复的元组个数

然后!=在SQL中用<>来表示


way 1:

select a.Email
from Person as a,Person as b
where a.Id <> b.Id and a.Email = b.Email

way 2:

select Email
from Person
group by Email
having count(*) > 1

SQL-Duplicate Emails的更多相关文章

  1. [SQL]LeetCode182. 查找重复的电子邮箱 | Duplicate Emails

    Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...

  2. 【SQL】182. Duplicate Emails

    Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...

  3. [LeetCode] Delete Duplicate Emails 删除重复邮箱

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  4. [LeetCode] Duplicate Emails 重复的邮箱

    Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...

  5. LeeCode(Database)-Duplicate Emails

    Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...

  6. Leetcode 182. Duplicate Emails

    Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...

  7. LeetCode DB: Duplicate Emails

    Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...

  8. LeetCode - Duplicate Emails

    Description:Write a SQL query to find all duplicate emails in a table named Person. 找出表中重复的Email. # ...

  9. 182. Duplicate Emails

    Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...

  10. Duplicate Emails

    Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...

随机推荐

  1. [Angular 2] ngrx/store

    @ngrx/store builds on the concepts made popular by Redux and supercharges it with the backing of RxJ ...

  2. 捕android程序崩溃日志

    主要类别: package com.example.callstatus; import java.io.File; import java.io.FileOutputStream; import j ...

  3. mysql02

    -- 查询课程名称 和年级的名称 -- 非等值连接查询 SELECT subjectname,gradeName FROM `subject`,grade -- 等值连接查询 SELECT subje ...

  4. asp.net+Sqlserver 通过存储过程读取数据

    Sqlserver代码  创建存储过程如下: /*根据父id获取类别总数*/ IF EXISTS (SELECT name FROM sysobjects WHERE name = N'getsite ...

  5. GridView、Repeater获取当前行号

    GridView: <%# Container.DataItemIndex+1 %> Repeater:<%# Container.ItemIndex+1%>

  6. Linux中 pid_t 类型的定义.

    说明:涉及到的头文件(.h),目录默认都是基于 /usr/include/ 目录. 1.在 "/sys/types.h"中,有下列内容: #include <bits/typ ...

  7. ajaxfileupload

                 }         }                              setTimeout(                              }, s. ...

  8. 武汉科技大学ACM:1010: 零起点学算法89——母牛的故事

    Problem Description 有一头母牛,它每年年初生一头小母牛.每头小母牛从第四个年头开始,每年年初也生一头小母牛.请编程实现在第n年的时候,共有多少头母牛? Input 输入数据由多个测 ...

  9. 关于操作DC时的资源泄露

    首先应明确一个概念 句柄, 关于句柄的详细介绍请见这里 对于句柄的使用小结:借来的要归还,创建的要释放,选出的要选入[尤其是针对GDI的一些句柄而言,如HPEN,HBRUSH等] 1. 使用GetDC ...

  10. c++虚函数的学习

    1.虚函数 #include<iostream.h> class Base { public: void print() { cout<<"Base"< ...