SQL刷题
mileitutu
某上市药企数字化运营中心の数据分析主管
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
SQL刷题(LeetCode-简单-196.删除重复邮箱)
deletefrom Personwhere Id in ( select Id from ( select Id, row_number() over(partition by Email order by Id) rn from Person ) t1 where rn>1 )使用窗口函数解题窗口函数可以解决什么问题?排名:每个班级按成绩来排名top N:找出每个学科排名前N的同学进行奖励总之:在每组内排名的问题.原创 2021-05-26 13:41:52 · 188 阅读 · 0 评论 -
SQL刷题(LeetCode-简单-183.从不订购的客户)
select c.`Name` as Customersfrom Orders as oright join Customers as con c.`Id` = o.`CustomerId`where o.`CustomerId` is null原创 2021-05-25 16:07:11 · 131 阅读 · 0 评论 -
SQL刷题(LeetCode-简单-182.查找重复的电子邮箱)
select p.`Email`from Person as pgroup by p.`Email`having count(*)>1对Email出现的次数进行计数,大于1的就说明重复了count(*)可以不出现在选择列表里原创 2021-05-25 15:11:38 · 182 阅读 · 0 评论 -
SQL刷题(LeetCode-简单-181.超过经理收入的员工)
select a.`Name` as Employeefrom Employee as a,Employee as bwhere a.`ManagerId` = b.`id`and a.`Salary` > b.`Salary` 使用自连接解题,根据筛选条件得到有经理的员工的经理的薪资,再比较员工和其经理的薪资。...原创 2021-05-25 14:36:06 · 141 阅读 · 0 评论 -
SQL刷题(LeetCode-简单-176.第二高的薪水)
select ifnull( (select distinct salary as SecondHighestSalary from Employee order by salary desc limit 1 offset 1) ,null)as SecondHighestSalary要点第二高的薪水可能为空,用ifnull解决。内层select语句形成了一个临时表.原创 2021-05-25 11:17:09 · 106 阅读 · 0 评论 -
SQL刷题(LeetCode-简单.175组合两个表)
两种代码执行性能有不小的差异第一种select p.`FirstName` ,p.`LastName` ,a.`City` ,a.`State`from Person as pleft join Address as aon p.`PersonId` = a.`PersonId`在这种方法中,查询列表规定了所查询字段的表名,性能如下:第二种select FirstName ,LastName ,City原创 2021-05-25 10:28:25 · 114 阅读 · 0 评论
分享