本帖最后由 mengyangchao 于 2011-01-05 09:03:01 编辑

解决方案 »

  1.   

    就是这一条update tmp_sgzjtj 
    set yyk=yfje
    from tmp_sgzjtj A,
    (select sum(yfje) yfje,B.yylxdm,B.wzhth from jsdzb A,gdhxx_jc B
    where A.wzhth=B.wzhth and A.zzjgdm like @dwdm+'%' and rq>=@crq1 and rq<=@crq2 and A.sjnd=@sjnd
    group by B.yylxdm,B.wzhth) B
    where yhdm=@yhdm and A.yylx=B.yylxdm and A.dwdm=B.wzhth
      

  2.   

    select * from tmp_sgzjtj A,
    (select sum(yfje) yfje,B.yylxdm,B.wzhth from jsdzb A,gdhxx_jc B
    where A.wzhth=B.wzhth and A.zzjgdm like @dwdm+'%' and rq>=@crq1 and rq<=@crq2 and A.sjnd=@sjnd
    group by B.yylxdm,B.wzhth) B
    where yhdm=@yhdm and A.yylx=B.yylxdm and A.dwdm=B.wzhth
    看看是否超时--再试试
    select * from tmp_sgzjtj where yhdm=@yhdm select sum(yfje) yfje,B.yylxdm,B.wzhth from jsdzb A,gdhxx_jc B
    where A.wzhth=B.wzhth and A.zzjgdm like @dwdm+'%' and rq>=@crq1 and rq<=@crq2 and A.sjnd=@sjnd
    group by B.yylxdm,B.wzhth
      

  3.   

    尝试把子查询放到临时表,再关联update 看看
      

  4.   

    --表另名重复
    update tmp_sgzjtj 
    set yyk=yfje
    from tmp_sgzjtj M,
    (select sum(yfje) yfje,B.yylxdm,B.wzhth from jsdzb A,gdhxx_jc B
    where A.wzhth=B.wzhth and A.zzjgdm like @dwdm+'%' and rq>=@crq1 and rq<=@crq2 and A.sjnd=@sjnd
    group by B.yylxdm,B.wzhth) N
    where yhdm=@yhdm and M.yylx=N.yylxdm and M.dwdm=N.wzhth
      

  5.   

    select sum(yfje) yfje,B.yylxdm,B.wzhth from jsdzb A,gdhxx_jc B
    where A.wzhth=B.wzhth and A.zzjgdm like @dwdm+'%' and rq>=@crq1 and rq<=@crq2 and A.sjnd=@sjnd
    group by B.yylxdm,B.wzhth这条?