Oracle with as 嵌套
oracle with as可以理解为临时视图,可以极大的简化sql语句,并且支持嵌套使用。
With c3 As(Select * From v_tr_daily Where p_date=to_date('2019-05-21','yyyy-mm-dd')) ,c1 As( Select type_id,dept_id,drill_dept,sum(mine_ore0) From c3 Where type_id=1 Group By type_id,dept_id,drill_dept ) Select * From c1
还可以用在insert语句中,如下:
insert into t1 With c3 As(Select * From v_tr_daily Where p_date=to_date('2019-05-21','yyyy-mm-dd')) ,c1 As( Select type_id,dept_id,drill_dept,sum(mine_ore0) From c3 Where type_id=1 Group By type_id,dept_id,drill_dept ) Select * From c1