with as 可以嵌套使用吗

0
在oracle数据库执行如下sql语句报错:
with tmp2 as(
with tmp1 as (select * from m_com_cust a)
select * from tmp1 t1 where t1.cust_no='3000059547')
select tmp2 t2 where t2.cust_name_en='UNKNOWN'
 
4.png
已邀请:
1

- 取是能力,舍是境界 2016-01-27 回答

With as 的嵌套是这样用的
 
With tmp as
(
select 1 abc from dual
)
,tmp2 as
(
 select 2 def,abc from tmp
)
select * from tmp2
 
 
WITH    tmp1
          AS ( SELECT   *
               FROM     m_com_cust a
             ) ,
        tmp2
          AS ( SELECT   *
               FROM     tmp1 t1
               WHERE    t1.cust_no = '3000059547'
             )
    SELECT  *
    FROM    tmp2 t2
    WHERE   t2.cust_name_en = 'UNKNOWN'
0

小耳朵 2016-01-27 回答

不是的,这样的with只能算并列,不是嵌套

要回复问题请先登录注册