zoukankan      html  css  js  c++  java
  • 3. Find Anagram Mappings

    Title:

    Write an SQL query to find all duplicate e-mails in the Person table.

    Example :

    case:

    +----+---------+
    | Id | Email   |
    +----+---------+
    | 1  | a@b.com |
    | 2  | c@d.com |
    | 3  | a@b.com |
    +----+---------+

    return:
    +---------+
    | Email   |
    +---------+
    | a@b.com |
    +---------+

    Note:

     All Email is lowercase letters.

    Analysis of Title:

    None

    Test case:

    {"headers": {"Person": ["Id", "Email"]}, "rows": {"Person": [[1, "a@b.com"], [2, "c@d.com"], [3, "a@b.com"]]}}

    MySQL:

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

    Analysis of Code:

    We need to return(or so-called select) Emali non-repetitive.

    The first key is 'all duplicate', so we need to 'group by'.

    The second key is 'repeated', so it means the count is greater than 1, so we select count(*>1)

  • 相关阅读:
    WSGI原理
    主从数据库
    mysql高级
    记录
    获取当前时间
    sql注入和防sql注入
    python操作MySQL
    修改Windows10 命令终端cmd的编码为UTF-8
    MySQL查询
    MySQL数据库操作
  • 原文地址:https://www.cnblogs.com/sxuer/p/10628772.html
Copyright © 2011-2022 走看看