leetcode sql
dodo_pig
这个作者很懒,什么都没留下…
展开
-
leetcode 569员工薪水中位数
###先对每个公司员工工资排序并增加一列序号,然后计算每个公司人数,把两部分join起来取每个公司序号为该公司(总数+1)/2的数据 select a.Id, a.Company, a.Salary from( select a., @num:=if(@company=Company, @num+1, 1) as num, @company:=Company from Employee as a,...原创 2019-08-19 20:16:13 · 530 阅读 · 0 评论 -
leetcode 185部门工资前三高的所有员工
select b.name as Department, a.name as Employee, a.Salary from( select a.*, @rank:=case when @department=DepartmentId and @salary<>salary then @rank+1 when @department...原创 2019-08-19 23:59:37 · 108 阅读 · 0 评论 -
leetcode 579查询员工的累积薪水
Employee表中有一年的员工薪资信息,写一个sql来获得3个月内员工工资的累计总和,但不包括最近一个月 方法一,待验证 select a.Id,a.Month, sum(Salary) as cu_salary from Employee as a join Employee as b on a.Id=b.Id and a.Month<=b.Month join( select Id...原创 2019-08-20 16:01:43 · 740 阅读 · 3 评论 -
leetcode 262行程和用户
##方法一 select Department, Employee, Salary from( select a.*, @rank:=case when @id=Department and @money<>Salary then @rank+1 when @id=Department and @money=Salary then ...原创 2019-08-26 16:37:25 · 136 阅读 · 0 评论 -
leetcode 601体育馆的人流量
select id, visit_date, people from( select a.*, @j:=if(@num2>=100 and people>=100, @j, @j+1) as orders, @num2:=people as peo from stadium as a, (select @num2:=0, @j:=0) as b ) as a whe...原创 2019-08-26 17:34:54 · 200 阅读 · 0 评论