数据库学习笔记(5)-----with as的用法(2019/2/28)
有如下表’student’
name | lesson | grade |
---|---|---|
Joson | Math | 95 |
Joson | Chinese | 25 |
Joson | English | 80 |
Joson | Biology | 75 |
Joson | Phycial | 55 |
此时,我们可以通过with as方式,将这张表拆分为N张表存进当前SQL窗口的缓存中,例如:
with stu_name as(
select name,lesson from student;
),stu_grade as(
select name,lesson,grade from student;
)
那么,将会有两张临时表被存入了缓存中,分别叫做’stu_name’和’stu_grade’
stu_name:
name | lesson |
---|---|
Joson | Math |
Joson | Chinese |
Joson | English |
Joson | Biology |