|
楼主 |
发表于 2008-4-4 21:22
|
显示全部楼层
浪潮"内部"资料,绝对经典2
<p>go<br/><br/>select F_VAL from BBCONF where F_VKEY='FORCE_ZW'</p><p>go<br/>select F_VAL from BBCONF where F_VKEY='ZW_YJZ'</p><p>go<br/>select count(1) from ZWPZK where ZWPZK_KJND<='2008' and ZWPZK_KJQJ<='03' and ZWPZK_JZF='0' and ZWPZK_WZF='1' and ZWPZK_ZFF='0'</p><p>go<br/>select F_VAL from LSCONF where F_VKEY='ZW_CSNDQJ'</p><p>go<br/>truncate table #bbpznmTmp364</p><p>go<br/>drop table #bbpznmTmp364</p><p>go<br/>create table #bbpznmTmp364 (F_KJND varchar(4) null,F_KJQJ varchar(2) null,F_PZNM varchar(9) null)</p><p>go<br/>create index #bbpznmTmp364 on #bbpznmTmp364 ( F_KJND,F_KJQJ,F_PZNM ) </p><p>go<br/>insert into #bbpznmTmp364(F_KJND,F_KJQJ,F_PZNM ) select ZWPZK_KJND,ZWPZK_KJQJ,ZWPZK_PZNM FROM ZWPZK where (ZWPZK_KJND<'2008' or </p><p>(ZWPZK_KJND='2008' and ZWPZK_KJQJ<='03')) and ZWPZK_JZF='0' and ZWPZK_WZF='1' and ZWPZK_ZFF='0'</p><p><br/>select count(ZWPZFL_KMBH) from ZWPZFL,#bbpznmTmp364 WHERE ZWPZFL_PZNM=#bbpznmTmp364.F_PZNM</p><p>go<br/>truncate table #bbkmjehz364</p><p>go<br/>drop table #bbkmjehz364</p><p>go<br/>create table #bbkmjehz364 (F_KJND varchar(4) null, F_KJQJ varchar(2) null, F_KMBH varchar(30) null, F_JFJE u001 default 0, F_DFJE u001 default 0, </p><p>F_JFSL u001 default 0, F_DFSL u001 default 0) </p><p>go<br/>create index #bbkmjehz364 on #bbkmjehz364 ( F_KJND,F_KJQJ,F_KMBH ) </p><p>go<br/>truncate table #bbkmhztmp364</p><p>go<br/>drop table #bbkmhztmp364</p><p>go<br/>create table #bbkmhztmp364 (F_KJND varchar(4) null, F_KJQJ varchar(2) null, F_KMBH varchar(30) null, F_JE u001 default 0, F_SL u001 default 0) </p><p>go<br/>create index #bbkmhztmp364 on #bbkmhztmp364 ( F_KJND,F_KJQJ,F_KMBH ) </p><p>go<br/>insert into #bbkmjehz364(F_KJND,F_KJQJ,F_KMBH,F_JFJE,F_JFSL,F_DFJE,F_DFSL) select #bbpznmTmp364.F_KJND,#bbpznmTmp364.F_KJQJ,ZWPZFL_KMBH, round(sum(round</p><p>(ZWPZFL_JE,2)),2), round(sum(round(ZWPZFL_SL,4)),4),0,0 from ZWPZFL,#bbpznmTmp364 WHERE ZWPZFL_PZNM=#bbpznmTmp364.F_PZNM and ZWPZFL_JZFX='1' group by </p><p>F_KJND,F_KJQJ,ZWPZFL_KMBH </p><p>go<br/>insert into #bbkmjehz364(F_KJND,F_KJQJ,F_KMBH,F_JFJE,F_JFSL,F_DFJE,F_DFSL) select #bbpznmTmp364.F_KJND,#bbpznmTmp364.F_KJQJ,ZWKMZD_KMBH, round(sum(round</p><p>(ZWPZFL_JE,2)),2), round(sum(round(ZWPZFL_SL,4)),4),0,0 from ZWKMZD,ZWPZFL,#bbpznmTmp364 WHERE ZWPZFL_PZNM=#bbpznmTmp364.F_PZNM and ZWPZFL_JZFX='1' AND </p><p>CHARINDEX(ZWKMZD_KMBH,ZWPZFL_KMBH)=1 and ZWKMZD_MX=0 group by F_KJND,F_KJQJ,ZWKMZD_KMBH </p><p>go<br/>insert into #bbkmhztmp364(F_KJND,F_KJQJ,F_KMBH,F_JE,F_SL) select #bbpznmTmp364.F_KJND,#bbpznmTmp364.F_KJQJ,ZWPZFL_KMBH, round(sum(round(ZWPZFL_JE,2)),2), </p><p>round(sum(round(ZWPZFL_SL,4)),4) from ZWPZFL,#bbpznmTmp364 WHERE ZWPZFL_PZNM=#bbpznmTmp364.F_PZNM and ZWPZFL_JZFX='2' group by F_KJND,F_KJQJ,ZWPZFL_KMBH </p><p>go<br/>insert into #bbkmhztmp364(F_KJND,F_KJQJ,F_KMBH,F_JE,F_SL) select #bbpznmTmp364.F_KJND,#bbpznmTmp364.F_KJQJ,ZWKMZD_KMBH, round(sum(round(ZWPZFL_JE,2)),2), </p><p>round(sum(round(ZWPZFL_SL,4)),4) from ZWKMZD,ZWPZFL,#bbpznmTmp364 WHERE ZWPZFL_PZNM=#bbpznmTmp364.F_PZNM and ZWPZFL_JZFX='2' AND CHARINDEX</p><p>(ZWKMZD_KMBH,ZWPZFL_KMBH)=1 AND ZWKMZD_MX=0 group by F_KJND,F_KJQJ,ZWKMZD_KMBH </p><p>go<br/>update #bbkmjehz364 set F_DFJE=F_JE,F_DFSL=F_SL from #bbkmjehz364,#bbkmhztmp364 where #bbkmjehz364.F_KJND=#bbkmhztmp364.F_KJND and </p><p>#bbkmjehz364.F_KJQJ=#bbkmhztmp364.F_KJQJ and #bbkmjehz364.F_KMBH=#bbkmhztmp364.F_KMBH </p><p>go<br/>insert into #bbkmjehz364 (F_KJND,F_KJQJ,F_KMBH,F_DFJE,F_DFSL,F_JFJE,F_JFSL ) select F_KJND,F_KJQJ,F_KMBH,F_JE,F_SL,0,0 from #bbkmhztmp364 where not exists</p><p>(select 1 from #bbkmjehz364 where #bbkmjehz364.F_KJND=#bbkmhztmp364.F_KJND and #bbkmjehz364.F_KJQJ=#bbkmhztmp364.F_KJQJ and </p><p>#bbkmjehz364.F_KMBH=#bbkmhztmp364.F_KMBH)</p><p>go<br/>truncate table #bbkmhztmp364</p><p>go<br/>drop table #bbkmhztmp364</p><p>go<br/>select count(ZWKMZD_KMBH) from ZWKMZD,ZWPZFL,#bbpznmTmp364 WHERE ZWKMZD_KMBH=ZWPZFL_KMBH AND ZWKMZD_HSWB<>'0' AND ZWPZFL_PZNM=#bbpznmTmp364.F_PZNM</p><p>go<br/>select count(ZWFZYS_KMBH) from ZWFZYS,#bbpznmTmp364 WHERE ZWFZYS_PZNM=#bbpznmTmp364.F_PZNM</p><p>go<br/>truncate table #bbfzjehz364</p><p>go<br/>drop table #bbfzjehz364</p><p>go<br/>create table #bbfzjehz364 (F_KJND varchar(4) null, F_KJQJ varchar(2) null, F_KMBH varchar(30) null, F_BMBH varchar(20) null, F_DWBH varchar(20) null, </p><p>F_ZGBH varchar(20) null, F_XM01 varchar(20) null, F_XM02 varchar(20) null, F_XM03 varchar(20) null, F_XM04 varchar(20) null, F_XM05 varchar(20) null, </p><p>F_JFJE u001 default 0, F_DFJE u001 default 0, F_JFSL u001 default 0, F_DFSL u001 default 0) </p><p>go<br/>create index #bbfzjehz364 on #bbfzjehz364 ( F_KJND,F_KJQJ,F_KMBH,F_BMBH,F_DWBH,F_ZGBH,F_XM01 ) </p><p>go<br/>truncate table #bbfzhztmp364</p><p>go<br/>drop table #bbfzhztmp364</p><p>go<br/>create table #bbfzhztmp364 (F_KJND varchar(4) null, F_KJQJ varchar(2) null, F_KMBH varchar(30) null, F_BMBH varchar(20) null, F_DWBH varchar(20) null, </p><p>F_ZGBH varchar(20) null, F_XM01 varchar(20) null, F_XM02 varchar(20) null, F_XM03 varchar(20) null, F_XM04 varchar(20) null, F_XM05 varchar(20) null, </p><p>F_JE u001 default 0, F_SL u001 default 0) </p><p>go<br/>create index #bbfzhztmp364 on #bbfzhztmp364 ( F_KJND,F_KJQJ,F_KMBH,F_BMBH,F_DWBH,F_ZGBH,F_XM01 ) </p><p>go<br/>insert into #bbfzjehz364(F_KJND,F_KJQJ,F_KMBH,F_BMBH,F_DWBH,F_ZGBH,F_XM01,F_XM02,F_XM03,F_XM04,F_XM05,F_JFJE,F_JFSL,F_DFJE,F_DFSL) select </p><p>#bbpznmTmp364.F_KJND,#bbpznmTmp364.F_KJQJ,ZWFZYS_KMBH,ISNULL(ZWFZYS_BMBH,' '),ISNULL(ZWFZYS_DWBH,' '),ISNULL(ZWFZYS_ZGBH,' '),ISNULL(ZWFZYS_XM01,' '),ISNULL</p><p>(ZWFZYS_XM02,' '),ISNULL(ZWFZYS_XM03,' '),ISNULL(ZWFZYS_XM04,' '),ISNULL(ZWFZYS_XM05,' '), round(sum(round(ZWFZYS_JE,2)),2), round(sum(round</p><p>(ZWFZYS_SL,4)),4),0,0 from ZWFZYS,#bbpznmTmp364 WHERE ZWFZYS_PZNM=#bbpznmTmp364.F_PZNM and ZWFZYS_JZFX='1' group by F_KJND,F_KJQJ,ZWFZYS_KMBH,isnull</p><p>(ZWFZYS_BMBH,' '),isnull(ZWFZYS_DWBH,' '),isnull(ZWFZYS_ZGBH,' '),isnull(ZWFZYS_XM01,' '),isnull(ZWFZYS_XM02,' '),isnull(ZWFZYS_XM03,' '),isnull</p><p>(ZWFZYS_XM04,' '),isnull(ZWFZYS_XM05,' ') </p><p>go<br/>insert into #bbfzhztmp364(F_KJND,F_KJQJ,F_KMBH,F_BMBH,F_DWBH,F_ZGBH,F_XM01,F_XM02,F_XM03,F_XM04,F_XM05,F_JE,F_SL) select </p><p>#bbpznmTmp364.F_KJND,#bbpznmTmp364.F_KJQJ,ZWFZYS_KMBH,ISNULL(ZWFZYS_BMBH,' '),ISNULL(ZWFZYS_DWBH,' '),ISNULL(ZWFZYS_ZGBH,' '),ISNULL(ZWFZYS_XM01,' '),ISNULL</p><p>(ZWFZYS_XM02,' '),ISNULL(ZWFZYS_XM03,' '),ISNULL(ZWFZYS_XM04,' '),ISNULL(ZWFZYS_XM05,' '), round(sum(round(ZWFZYS_JE,2)),2), round(sum(round</p><p>(ZWFZYS_SL,4)),4) from ZWFZYS,#bbpznmTmp364 WHERE ZWFZYS_PZNM=#bbpznmTmp364.F_PZNM and ZWFZYS_JZFX='2' group by F_KJND,F_KJQJ,ZWFZYS_KMBH,ISNULL</p><p>(ZWFZYS_BMBH,' '),ISNULL(ZWFZYS_DWBH,' '),ISNULL(ZWFZYS_ZGBH,' '),ISNULL(ZWFZYS_XM01,' '),ISNULL(ZWFZYS_XM02,' '),ISNULL(ZWFZYS_XM03,' '),ISNULL</p><p>(ZWFZYS_XM04,' '),ISNULL(ZWFZYS_XM05,' ') </p><p>go<br/>update #bbfzjehz364 set F_DFJE= F_JE,F_DFSL=F_SL FROM #bbfzjehz364,#bbfzhztmp364 where #bbfzjehz364.F_KJND=#bbfzhztmp364.F_KJND and </p><p>#bbfzjehz364.F_KJQJ=#bbfzhztmp364.F_KJQJ and #bbfzjehz364.F_KMBH=#bbfzhztmp364.F_KMBH and #bbfzjehz364.F_BMBH=#bbfzhztmp364.F_BMBH and </p><p>#bbfzjehz364.F_DWBH=#bbfzhztmp364.F_DWBH and #bbfzjehz364.F_ZGBH=#bbfzhztmp364.F_ZGBH and #bbfzjehz364.F_XM01=#bbfzhztmp364.F_XM01 and </p><p>#bbfzjehz364.F_XM02=#bbfzhztmp364.F_XM02 and #bbfzjehz364.F_XM03=#bbfzhztmp364.F_XM03 and #bbfzjehz364.F_XM04=#bbfzhztmp364.F_XM04 and </p><p>#bbfzjehz364.F_XM05=#bbfzhztmp364.F_XM05 </p><p>go<br/>insert into #bbfzjehz364 (F_KJND,F_KJQJ,F_KMBH,F_BMBH,F_DWBH,F_ZGBH,F_XM01,F_XM02,F_XM03,F_XM04,F_XM05,F_DFJE,F_DFSL,F_JFJE,F_JFSL ) select </p><p>F_KJND,F_KJQJ,F_KMBH,F_BMBH,F_DWBH,F_ZGBH,F_XM01,F_XM02,F_XM03,F_XM04,F_XM05,F_JE,F_SL,0,0 from #bbfzhztmp364 where not exists(select 1 from #bbfzjehz364 </p><p>where #bbfzjehz364.F_KJND=#bbfzhztmp364.F_KJND and #bbfzjehz364.F_KJQJ=#bbfzhztmp364.F_KJQJ and #bbfzjehz364.F_KMBH=#bbfzhztmp364.F_KMBH and </p><p>#bbfzjehz364.F_BMBH=#bbfzhztmp364.F_BMBH and #bbfzjehz364.F_DWBH=#bbfzhztmp364.F_DWBH and #bbfzjehz364.F_ZGBH=#bbfzhztmp364.F_ZGBH and </p><p>#bbfzjehz364.F_XM01=#bbfzhztmp364.F_XM01 and #bbfzjehz364.F_XM02=#bbfzhztmp364.F_XM02 and #bbfzjehz364.F_XM03=#bbfzhztmp364.F_XM03 and </p><p>#bbfzjehz364.F_XM04=#bbfzhztmp364.F_XM04 and #bbfzjehz364.F_XM05=#bbfzhztmp364.F_XM05)</p><p>go<br/>truncate table #bbfzhztmp364</p><p>go<br/>drop table #bbfzhztmp364</p><p>go<br/>select count(ZWFZYS_KMBH) from ZWFZYS,ZWKMZD,#bbpznmTmp364 WHERE ZWKMZD_KMBH=ZWFZYS_KMBH AND ZWKMZD_HSWB<>'0' AND ZWFZYS_PZNM=#bbpznmTmp364.F_PZNM</p><p>go<br/>truncate table ZWKMJEBB364</p><p>go<br/>insert into ZWKMJEBB364 select * from ZWKMJE where ZWKMJE_KJND<='2008'</p><p>go<br/>truncate table ZWKMSLBB364</p><p>go<br/>insert into ZWKMSLBB364 select * from ZWKMSL where ZWKMSL_KJND<='2008'</p><p>go<br/>truncate table ZWKMWBBB364</p><p>go<br/>insert into ZWKMWBBB364 select * from ZWKMWB where ZWKMWB_KJND<='2008'</p><p>go<br/>truncate table ZWFZJEBB364</p><p>go<br/>insert into ZWFZJEBB364 select * from ZWFZJE where ZWFZJE_KJND<='2008'</p><p>go<br/>truncate table ZWFZSLBB364</p><p>go<br/>insert into ZWFZSLBB364 select * from ZWFZSL where ZWFZSL_KJND<='2008'</p><p>go<br/>truncate table ZWFZWBBB364</p><p>go<br/>insert into ZWFZWBBB364 select * from ZWFZWB where ZWFZWB_KJND<='2008'</p><p>go<br/>select F_KJND,F_KJQJ from #bbpznmTmp364 group by F_KJND,F_KJQJ order by F_KJND,F_KJQJ </p><p>go<br/>UPDATE ZWKMJEBB364 SET ZWKMJE_DQYE=round(round(ZWKMJE_DQYE,2) +round(#bbkmjehz364.F_JFJE,2) -round(#bbkmjehz364.F_DFJE,2),2) </p><p>FROM ZWKMJEBB364,#bbkmjehz364 WHERE ZWKMJE_KJND='2007' AND ZWKMJE_KJQJ>='06' AND F_KJND='2007' AND F_KJQJ='06' AND ZWKMJE_KMBH=#bbkmjehz364.F_KMBH AND </p><p>ZWKMJE_KMBH IN(SELECT ZWKMZD_KMBH FROM ZWKMZD WHERE ZWKMZD_XZ='0') </p><p>go<br/>UPDATE ZWKMJEBB364 SET ZWKMJE_NCYE= round(round(ZWKMJE_NCYE,2) +round(#bbkmjehz364.F_JFJE,2) -round</p><p>(#bbkmjehz364.F_DFJE,2),2), ZWKMJE_DQYE=round(round(ZWKMJE_DQYE,2) +round(#bbkmjehz364.F_JFJE,2) -round</p><p>(#bbkmjehz364.F_DFJE,2),2) FROM ZWKMJEBB364,#bbkmjehz364 WHERE ZWKMJE_KJND='2008' AND F_KJND='2007' AND F_KJQJ='06' AND ZWKMJE_KMBH=#bbkmjehz364.F_KMBH </p><p>AND ZWKMJE_KMBH IN(SELECT ZWKMZD_KMBH FROM ZWKMZD WHERE ZWKMZD_XZ='0') </p><p>go<br/>UPDATE ZWKMJEBB364 SET ZWKMJE_JFLJ=round(round(ZWKMJE_JFLJ,2)+round(#bbkmjehz364.F_JFJE,2),2), ZWKMJE_DFLJ=round(round(ZWKMJE_DFLJ,2)+round</p><p>(#bbkmjehz364.F_DFJE,2),2) FROM ZWKMJEBB364,#bbkmjehz364 WHERE ZWKMJE_KJND='2007' AND ZWKMJE_KJQJ>='06' AND F_KJND='2007' AND F_KJQJ='06' AND </p><p>ZWKMJE_KMBH=#bbkmjehz364.F_KMBH </p><p>go<br/>UPDATE ZWKMJEBB364 SET ZWKMJE_JFFS=round(round(ZWKMJE_JFFS,2)+round(#bbkmjehz364.F_JFJE,2),2), ZWKMJE_DFFS=round(round(ZWKMJE_DFFS,2)+round</p><p>(#bbkmjehz364.F_DFJE,2),2) FROM ZWKMJEBB364,#bbkmjehz364 WHERE ZWKMJE_KJND='2007' AND ZWKMJE_KJQJ='06' AND F_KJND='2007' AND F_KJQJ='06' AND </p><p>ZWKMJE_KMBH=#bbkmjehz364.F_KMBH </p><p>go<br/>UPDATE ZWKMSLBB364 SET ZWKMSL_DQYE=round(round(ZWKMSL_DQYE,4)+round(#bbkmjehz364.F_JFSL,4)-round(#bbkmjehz364.F_DFSL,4),4) FROM ZWKMSLBB364,#bbkmjehz364 </p><p>WHERE ZWKMSL_KJND='2007' AND ZWKMSL_KJQJ>='06' and F_KJND='2007' and F_KJQJ='06' AND ZWKMSL_KMBH=#bbkmjehz364.F_KMBH AND ZWKMSL_KMBH IN(SELECT ZWKMZD_KMBH </p><p>FROM ZWKMZD WHERE ZWKMZD_XZ='0') </p><p>go<br/>UPDATE ZWKMSLBB364 SET ZWKMSL_NCYE=round(round(ZWKMSL_NCYE,4)+round(#bbkmjehz364.F_JFSL,4)-round(#bbkmjehz364.F_DFSL,4),4), ZWKMSL_DQYE=round(round</p><p>(ZWKMSL_DQYE,4)+round(#bbkmjehz364.F_JFSL,4)-round(#bbkmjehz364.F_DFSL,4),4) FROM ZWKMSLBB364,#bbkmjehz364 WHERE ZWKMSL_KJND='2008' and F_KJND='2007' and </p><p>F_KJQJ='06' AND ZWKMSL_KMBH=#bbkmjehz364.F_KMBH AND ZWKMSL_KMBH IN(SELECT ZWKMZD_KMBH FROM ZWKMZD WHERE ZWKMZD_XZ='0') </p><p>go<br/>UPDATE ZWKMSLBB364 SET ZWKMSL_JFLJ=round(round(ZWKMSL_JFLJ,4)+round(#bbkmjehz364.F_JFSL,4),4), ZWKMSL_DFLJ=round(round(ZWKMSL_DFLJ,4)+round</p><p>(#bbkmjehz364.F_DFSL,4),4) FROM ZWKMSLBB364,#bbkmjehz364 WHERE ZWKMSL_KJND='2007' AND ZWKMSL_KJQJ>='06' and F_KJND='2007' and F_KJQJ='06' AND </p><p>ZWKMSL_KMBH=#bbkmjehz364.F_KMBH </p><p>go<br/>UPDATE ZWKMSLBB364 SET ZWKMSL_JFFS=round(round(ZWKMSL_JFFS,4)+round(#bbkmjehz364.F_JFSL,4),4), ZWKMSL_DFFS=round(round(ZWKMSL_DFFS,4)+round</p><p>(#bbkmjehz364.F_DFSL,4),4) FROM ZWKMSLBB364,#bbkmjehz364 WHERE ZWKMSL_KJND='2007' AND ZWKMSL_KJQJ='06' and F_KJND='2007' and F_KJQJ='06' AND </p><p>ZWKMSL_KMBH=#bbkmjehz364.F_KMBH <br/></p>
[此贴子已经被作者于2008-4-5 9:47:16编辑过] |
|