美文网首页
MySQL练习-温故而知新,再见恍若隔世

MySQL练习-温故而知新,再见恍若隔世

作者: ShowMeCoding | 来源:发表于2022-02-20 19:56 被阅读0次
    175. 组合两个表
    select firstname, lastname, city, state
    from person left join Address
    on person.PersonId = Address.PersonId
    ;
    
    181. 超过经理收入的员工
    SELECT
        a.Name AS 'Employee'
    FROM
        Employee AS a,
        Employee AS b
    WHERE
        a.ManagerId = b.Id
            AND a.Salary > b.Salary
    ;
    
    182. 查找重复的电子邮箱
    select Email from
    (
        select Email, count(Email) as num
        from Person
        group by Email
    )  as statistic
    where num > 1;
    
    183. 从不订购的客户
    select customers.name as 'Customers'
    from customers
    where customers.id not in 
    (
        select customerid from orders
    )
    ;
    
    196. 删除重复的电子邮箱
    delete p1 from person p1, person p2
    where p1.email = p2.email and p1.id > p2.id
    
    197. 上升的温度
    select 
        weather.id as 'id'
    from weather join weather w on DATEDIFF(weather.recordDate, w.recordDate) = 1
        and weather.Temperature > w.Temperature
    ;
    

    相关文章

      网友评论

          本文标题:MySQL练习-温故而知新,再见恍若隔世

          本文链接:https://www.haomeiwen.com/subject/hkuvlrtx.html