update ys_dca03
 set dym = (select case when jtys = 400 then isnull(ymbcd, 0) * 2
                        else  case  when isnull(jgbcd, 0) / case when isnull(xzjgs, 0) = 0 then       null else  isnull(xzjgs,0) end =0 then null 
                                    else round(isnull(ymbcd, 0) / (isnull(jgbcd, 0) /case when isnull(xzjgs, 0) = 0 then null else  isnull(xzjgs,0) end) * ygpjcd, 1) end 
                        end dym
                from ys_dca03 a
               where ys_dca03.jcdm = '108'
                 and ys_dca03.jcdm = a.jcdm
                 and ys_dca03.jh = a.jh
                 and ys_dca03.csrq = a.csrq
                 and a.dym is null)
 where jcdm = '108'
   and dym is null这段中的条件where ys_dca03.jcdm = '108'
      and ys_dca03.jcdm = a.jcdm
      and ys_dca03.jh = a.jh
      and ys_dca03.csrq = a.csrq
是什么意思? ys_dca03不就是a吗?

解决方案 »

  1.   

    ys_dca03可能指的是
    update ys_dca03   中的 表
      

  2.   

    表的批量更新,更新满足条件 jcdm = '108'  and dym is null的所有记录,且按照jcdm,jh,csrq分别各自更新
      

  3.   

    那可以写成这样吗?
    where ys_dca03.jcdm = '108' 
    and ys_dca03.jcdm = ys_dca03.jcdm 
    and ys_dca03.jh = ys_dca03.jh 
    and ys_dca03.csrq = ys_dca03.csrq 
    and ys_dca03.dym is null或者 
    where a.jcdm = '108' 
    and a.jcdm = a.jcdm 
    and a.jh = a.jh 
    and a.csrq = a.csrq 
    and a.dym is null