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

2022-02-20  本文已影响0人  ShowMeCoding
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
;
上一篇下一篇

猜你喜欢

热点阅读