就是这一条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
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
尝试把子查询放到临时表,再关联update 看看
--表另名重复 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
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这条?
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
(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
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
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这条?