WITH AS用法
单个临时表语法格式:with tmp as (select * from tb_name)
多个临时表的语法:
with
tmp as (select * from tb_name),
tmp2 as (select * from tb_name2),
tmp3 as (select * from tb_name3)
作用:
(1)SQL可读性增强,更有层次感。
(2)with子查询只执行一次,将结果存储在用户临时表空间中,可以引用多次,增强性能。
(3)将几个临时表建立关联
例子: