时间:2021-07-01 10:21:17 帮助过:77人阅读
select * from _tempTable
例子:
with _tempStudent as(
select * from t_student t where class = '初二3班'
)
select sex,count(1) nums from _tempStudent where sex = '男' and height > '170'
union all
select sex,count(1) nums from _tempStudent where sex = '女' and height > '160'
多个with as 用法 每个临时存量直接用 "," 隔开
with t1 as (
select * from student where name in('张三','李四')
),t2 as (
select * from student where name in('王五')
)
select * from t1
union
select * from t2
如果with as 有嵌套的情况, 多个with as,后面的as内部可以直接调用先声明的临时对象
with t1 as (
select * from student where name in('张三','李四')
),t2 as (
select * from t1 where name in('王五')
)
select * from t2
oracle with as 用法
标签:oracle with as 查询结果重复使用