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

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
;
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 题目选自leetcode 上的题库 可能不一定都是最优解,答案仅供参考每道题后面都应相应的难度等级,如果没时间做的...
    顾子豪阅读 880评论 0 6
  • 175. 组合两个表[https://leetcode-cn.com/problems/combine-two-t...
    寒江老翁阅读 248评论 0 0
  • 181. 超过经理收入的员工[https://leetcode-cn.com/problems/employees...
    1nvad3r阅读 200评论 0 0
  • 新开一个帖子记录SQL的漫漫长征~ Day 1 leecode SQL 175 表1: Person +-----...
    noob鸽阅读 360评论 0 0
  • 凡例:1.对于题目只放出题目的编号、题目和链接;2.题目按照通过率排序;3.解答会放出mysql语言的代码,其他语...
    Lykit01阅读 1,572评论 2 7

友情链接更多精彩内容