认识临时表

1077. 项目员工 III - 力扣(LeetCode)

观察下面两条sql语句:

select a.project_id,a.employee_id from
(select p.project_id,p.employee_id,dense_rank() over(partition by p.project_id
 order by e.experience_years desc) as rk 
from project p left join employee e
on p.employee_id=e.employee_id) as a
where a.rk=1
select project_id,employee_id from
(select p.project_id,p.employee_id,dense_rank() over(partition by p.project_id
 order by e.experience_years desc) as rk 
from project p left join employee e
on p.employee_id=e.employee_id) a
where rk=1

具体先看临时表的内容:它是不带p和e的

这里写个a,只是为了写别名而写别名,不写别名会导致运行出错;所易关于临时表,在最后提取内容的时候可以加临时表名称,也可以不加名称。

©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页