update #SP_GL_BAL_T set
      BEG_DR_AMT = isnull((select sum(BEG_DR_AMT) from #SP_GL_BAL_T
        where RECLEVEL=0 and CODE1 like T.CODE1 + '%'), 0)      from #SP_GL_BAL_T T
      where RECLEVEL=1 
------------------------------>>>
update SP_GL_BAL_T 
set
BEG_DR_AMT=(select nvl(sum(BEG_DR_AMT),0) from SP_GL_BAL_T
              where RECLEVEL=0 and CODE1 like T.CODE1 + '%')
where RECLEVEL=1

解决方案 »

  1.   

    update SP_GL_BAL_T t set
          BEG_DR_AMT = nvl((select sum(BEG_DR_AMT) from SP_GL_BAL_T
            where RECLEVEL=0 and CODE1 like T.CODE1||'%'), 0)
          where RECLEVEL=1 
      

  2.   

    NVL(expr1, expr2)
      
    Purpose 
     If expr1 is null, returns expr2; if expr1 is not null, returns expr1. The arguments expr1 and expr2 can have any datatype. If their datatypes are different, Oracle converts expr2 to the datatype of expr1 before comparing them. The datatype of the return value is always the same as the datatype of expr1, unless expr1 is character data, in which case the return value's datatype is VARCHAR2.