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

 

相关文章:

  • 2021-06-26
  • 2022-02-02
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
猜你喜欢
  • 2021-05-16
  • 2022-03-11
  • 2022-12-23
  • 2022-01-07
  • 2022-01-12
相关资源
相似解决方案