34,576
社区成员
发帖
与我相关
我的任务
分享
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
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 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