《工作底稿 -个别报表指标数-资产负债表》

  1. select '个别报表数' as 标题,
  2. t.iyear as 年度,t.iperiod as 期间,t.hbcompany as 合并单位,t.biaoyang as 指标类型,t.rownum as 行号,t.indexname as 指标名称,
  3. t.ordernum as 行次,t1.localmoney as 本币金额,t1.wbmoney as 外币金额
  4. from
  5. (
  6. select *
  7. from
  8. (
  9. select distinct iyear,iperiod,hbcompany
  10. from
  11. (
  12. select distinct iyear,iperiod,companyParent as hbcompany from VW_CO_JC_Account_InvestmentParent01
  13. where 1=1 and invenstmentRatio>0 and iyear=$(合并报表-年度) and iperiod=$(合并报表-期间)
  14. union all
  15. select distinct iyear,iperiod,companyname as hbcompany from VW_CO_JC_Account_InvestmentParent01
  16. where 1=1 and invenstmentRatio>0 and iyear=$(合并报表-年度) and iperiod=$(合并报表-期间)
  17. ) as tt
  18. ) a
  19. cross join
  20. (select * from VW_CO_HB_index where biaoyang in ('A资产负债表','B资产负债表')) b
  21. )t
  22. left join
  23. (
  24. select 'A资产负债表' as biaoyang, iyear,iperiod,hbcompanyname,rownum,zcindexname as indexname,sum(zclocalqm) as localmoney,sum(zcwbqm) as wbmoney
  25. from CO_GB_BalanceSheet
  26. where isbook = '$(合并报表-是否包含未记账)'
  27. group by iyear,iperiod,hbcompanyname,rownum,zcindexname
  28. union all
  29. select 'B资产负债表' as biaoyang, iyear,iperiod,hbcompanyname,rownum,fzqyindexname as indexname,sum(fzqylocalqm) as localmoney,sum(fzqywbqm) as wbmoney
  30. from CO_GB_BalanceSheet
  31. where isbook = '$(合并报表-是否包含未记账)'
  32. group by iyear,iperiod,hbcompanyname,rownum,fzqyindexname
  33. ) t1 on t.iyear=t1.iyear and t.iperiod=t1.iperiod and t.hbcompany=t1.hbcompanyname and t.biaoyang=t1.biaoyang and t.rownum=t1.rownum
  34. where t.indexname is not null
  35. order by t.biaoyang,t.rownum

《工作底稿 - 抵消调整与合并-资产负债表》

  1. begin
  2. select t.iyear as 年度,t.iperiod as 期间,t.biaoyang as 指标类型,t.rownum as 行号,t.indexname as 指标名称,
  3. --t1.hbcompanyname,
  4. t.ordernum as 行次,sum(t1.localmoney) as 本币金额,sum(t1.wbmoney) as 外币金额
  5. into #temp_dixiaoauto000
  6. from
  7. (
  8. select *
  9. from
  10. (
  11. select distinct iyear,iperiod,hbcompany
  12. from
  13. (
  14. select distinct iyear,iperiod,companyParent as hbcompany from VW_CO_JC_Account_InvestmentParent01
  15. where 1=1 and invenstmentRatio>0 and iyear=$(合并报表-年度) and iperiod=$(合并报表-期间)
  16. union all
  17. select distinct iyear,iperiod,companyname as hbcompany from VW_CO_JC_Account_InvestmentParent01
  18. where 1=1 and invenstmentRatio>0 and iyear=$(合并报表-年度) and iperiod=$(合并报表-期间)
  19. ) as tt
  20. ) a
  21. cross join
  22. (select * from VW_CO_HB_index where biaoyang in ('A资产负债表','B资产负债表')) b
  23. )t
  24. left join
  25. (
  26. select 'A资产负债表' as biaoyang, iyear,iperiod,hbcompanyname,rownum,zcindexname as indexname,sum(zclocalqm) as localmoney,sum(zcwbqm) as wbmoney
  27. from CO_GB_BalanceSheet
  28. where isbook = '$(合并报表-是否包含未记账)'
  29. group by iyear,iperiod,hbcompanyname,rownum,zcindexname
  30. union all
  31. select 'B资产负债表' as biaoyang, iyear,iperiod,hbcompanyname,rownum,fzqyindexname as indexname,sum(fzqylocalqm) as localmoney,sum(fzqywbqm) as wbmoney
  32. from CO_GB_BalanceSheet
  33. where isbook = '$(合并报表-是否包含未记账)'
  34. group by iyear,iperiod,hbcompanyname,rownum,fzqyindexname
  35. ) t1 on t.iyear=t1.iyear and t.iperiod=t1.iperiod and t.hbcompany=t1.hbcompanyname and t.biaoyang=t1.biaoyang and t.rownum=t1.rownum
  36. where t.iyear=$(合并报表-年度) and t.iperiod=$(合并报表-期间)
  37. group by t.iyear,t.iperiod,t.biaoyang,t.rownum,t.indexname,t.ordernum,t1.iyear,t1.iperiod,t1.biaoyang
  38. select t.dxtypename as 抵消指标类型,t.rownum as 行号,
  39. t.iyear as 年度,t.iperiod as 月份,t.dxgroupname as 抵消规则,t.hbglcompany as 往来单位,
  40. t.benfangcompany as 本方单位,t.duifangcompany as 对方单位,t.indexname as 指标名称,
  41. case when t.ccodefx='借' then t.localbq else NULL end as 本币借方金额,
  42. case when t.ccodefx='贷' then t.localbq else NULL end as 本币贷方金额,
  43. case when t.ccodefx='借' then t.wbbq else NULL end as 外币借方金额,
  44. case when t.ccodefx='贷' then t.wbbq else NULL end as 外币贷方金额
  45. into #temp_dixiaoauto111
  46. from CO_DX_Auto_mx t
  47. where 1=1
  48. and tablename='资产负债表'
  49. and iyear=$(合并报表-年度)
  50. and iperiod=$(合并报表-期间)
  51. and isbook = '$(合并报表-是否包含未记账)'
  52. order by t.iyear,t.iperiod,t.dxtypename,t.dxgroupname,t.hbglcompany,t.benfangcompany,t.duifangcompany
  53. select 抵消指标类型,t1.rownum as 行号,
  54. t.年度,t.月份,t.抵消规则,t.往来单位,
  55. t.本方单位,t.对方单位,t1.indexname as 指标名称,
  56. sum(t.本币借方金额*(case when t1.jsfs='加' then 1 else -1 end )) as 本币借方金额,
  57. sum(t.本币贷方金额*(case when t1.jsfs='加' then 1 else -1 end )) as 本币贷方金额,
  58. sum(t.外币借方金额*(case when t1.jsfs='加' then 1 else -1 end )) as 外币借方金额,
  59. sum(t.外币贷方金额*(case when t1.jsfs='加' then 1 else -1 end )) as 外币贷方金额
  60. into #temp_dixiaoauto222
  61. from #temp_dixiaoauto111 t
  62. inner join
  63. (
  64. select distinct dxtype,dbtype,hbcompanyname,iyear,iperiod,rownum,indexname,jsindexname,jsfs
  65. from VW_CO_JC_indexname_GS
  66. ) t1 on t.指标名称=t1.jsindexname
  67. --and t.抵消指标类型=t1.dxtype
  68. and t.年度=t1.iyear and t.月份=t1.iperiod and t.本方单位=t1.hbcompanyname
  69. group by 抵消指标类型,t1.rownum,t.年度,t.月份,t.抵消规则,t.往来单位,t.本方单位,t.对方单位,t1.indexname
  70. select SUBSTRING(indexname, 1, CHARINDEX('-', indexname) - 1) as 抵消指标类型,
  71. SUBSTRING(SUBSTRING(indexname, CHARINDEX('-', indexname) + 1, 100), 1, CHARINDEX('-', SUBSTRING(indexname, CHARINDEX('-', indexname) + 1, 100)) - 1) as 行号,
  72. iyear as 年度,iperiod as 月份,dxgroupname as 抵消规则,hbcompany as 往来单位,
  73. benfangcompany as 本方单位,duifangcompany as 对方单位,
  74. SUBSTRING(indexname, CHARINDEX('-', indexname) + CHARINDEX('-', SUBSTRING(indexname, CHARINDEX('-', indexname) + 1, 100)) + 1, 100) as 指标名称,
  75. localmoney as 本币调整金额,wbmoney as 外币调整金额
  76. into #temp_dixiaoauto333
  77. from CO_DX_Adjust
  78. where 1=1
  79. and SUBSTRING(indexname, 1, CHARINDEX('-', indexname) - 1)='资产负债表'
  80. and iyear=$(合并报表-年度)
  81. and iperiod=$(合并报表-期间)
  82. select 抵消指标类型,t1.rownum as 行号,
  83. t.年度,t.月份,t.抵消规则,t.往来单位,
  84. t.本方单位,t.对方单位,t1.indexname as 指标名称,
  85. sum(t.本币调整金额*(case when t1.jsfs='加' then 1 else -1 end )) as 本币调整金额,
  86. sum(t.外币调整金额*(case when t1.jsfs='加' then 1 else -1 end )) as 外币调整金额
  87. into #temp_dixiaoauto444
  88. from #temp_dixiaoauto333 t
  89. inner join
  90. (
  91. select distinct dxtype,dbtype,hbcompanyname,iyear,iperiod,rownum,indexname,jsindexname,jsfs
  92. from VW_CO_JC_indexname_GS
  93. ) t1 on t.指标名称=t1.jsindexname
  94. --and t.抵消指标类型=t1.dxtype
  95. and t.年度=t1.iyear and t.月份=t1.iperiod and t.本方单位=t1.hbcompanyname
  96. group by 抵消指标类型,t1.rownum,t.年度,t.月份,t.抵消规则,t.往来单位,t.本方单位,t.对方单位,t1.indexname
  97. select t.iyear as 年度,t.iperiod as 期间,t.biaoyang as 指标类型,
  98. t.rownum as 行号,t.indexname as 指标名称,t.ordernum as 行次,
  99. t0.本币金额 as 个别汇总本币金额,t0.外币金额 as 个别汇总外币金额,
  100. t1.本币借方金额 as 本币借方金额,t1.本币贷方金额 as 本币贷方金额,
  101. t1.外币借方金额 as 外币借方金额,t1.外币贷方金额 as 外币贷方金额,
  102. t2.本币调整金额 as 本币调整金额,t2.外币调整金额 as 外币调整金额,
  103. t0.本币金额-isnull(t1.本币借方金额,0)-isnull(t1.本币贷方金额,0)-isnull(t2.本币调整金额,0) as 合并本币金额,
  104. t0.外币金额-isnull(t1.外币借方金额,0)-isnull(t1.外币贷方金额,0)-isnull(t2.外币调整金额,0) as 合并外币金额
  105. from
  106. (
  107. select *
  108. from
  109. (select $(合并报表-年度) as iyear,$(合并报表-期间) as iperiod) a
  110. cross join (select * from VW_CO_HB_index where biaoyang in ('A资产负债表','B资产负债表')) b
  111. )t
  112. left join #temp_dixiaoauto000 as t0
  113. on t.iyear=t0.年度 and t.iperiod=t0.期间 and t.rownum=t0.行号 and t.indexname=t0.指标名称 and t.biaoyang=t0.指标类型
  114. left join
  115. (
  116. select t.年度 as 年度,t.月份 as 期间,t.行号 as 行号,t.指标名称,
  117. sum(本币借方金额) as 本币借方金额,
  118. sum(本币贷方金额) as 本币贷方金额,
  119. sum(外币借方金额) as 外币借方金额,
  120. sum(外币贷方金额) as 外币贷方金额
  121. from
  122. (
  123. select * from #temp_dixiaoauto111
  124. union all
  125. select * from #temp_dixiaoauto222
  126. )t
  127. group by t.年度,t.月份,t.行号,t.指标名称
  128. ) t1 on t.iyear=t1.年度 and t.iperiod=t1.期间 and t.rownum=t1.行号 and t.indexname=t1.指标名称
  129. left join
  130. (
  131. select t.年度 as 年度,t.月份 as 期间,t.行号 as 行号,t.指标名称,
  132. sum(本币调整金额) as 本币调整金额,
  133. sum(外币调整金额) as 外币调整金额
  134. from
  135. (
  136. select * from #temp_dixiaoauto333
  137. union all
  138. select * from #temp_dixiaoauto444
  139. )t
  140. group by t.年度,t.月份,t.行号,t.指标名称
  141. ) t2 on t.iyear=t2.年度 and t.iperiod=t2.期间 and t.rownum=t2.行号 and t.indexname=t2.指标名称
  142. where 1=1 and t.indexname is not null
  143. order by t.biaoyang,t.rownum
  144. drop table #temp_dixiaoauto000;
  145. drop table #temp_dixiaoauto111;
  146. drop table #temp_dixiaoauto222;
  147. drop table #temp_dixiaoauto333;
  148. drop table #temp_dixiaoauto444;
  149. end

《工作底稿 -个别报表指标数资产负债表年初》

  1. select '个别报表数' as 标题,
  2. t.iyear as 年度,t.iperiod as 期间,t.hbcompany as 合并单位,t.biaoyang as 指标类型,t.rownum as 行号,t.indexname as 指标名称,
  3. t.ordernum as 行次,t1.localmoney as 本币金额,t1.wbmoney as 外币金额
  4. from
  5. (
  6. select *
  7. from
  8. (
  9. select distinct iyear,iperiod,hbcompany
  10. from
  11. (
  12. select distinct iyear,iperiod,companyParent as hbcompany from VW_CO_JC_Account_InvestmentParent01
  13. where 1=1 and invenstmentRatio>0 and iyear=$(合并报表-年度) and iperiod=$(合并报表-期间)
  14. union all
  15. select distinct iyear,iperiod,companyname as hbcompany from VW_CO_JC_Account_InvestmentParent01
  16. where 1=1 and invenstmentRatio>0 and iyear=$(合并报表-年度) and iperiod=$(合并报表-期间)
  17. ) as tt
  18. ) a
  19. cross join
  20. (select * from VW_CO_HB_index where biaoyang in ('A资产负债表','B资产负债表')) b
  21. )t
  22. left join
  23. (
  24. select 'A资产负债表' as biaoyang, iyear,iperiod,hbcompanyname,rownum,zcindexname as indexname,sum(zclocalnc) as localmoney,sum(zcwbnc) as wbmoney
  25. from CO_GB_BalanceSheet
  26. where isbook = '$(合并报表-是否包含未记账)' and iyear=$(合并报表-年度) and iperiod=$(合并报表-期间)
  27. group by iyear,iperiod,hbcompanyname,rownum,zcindexname
  28. union all
  29. select 'B资产负债表' as biaoyang, iyear,iperiod,hbcompanyname,rownum,fzqyindexname as indexname,sum(fzqylocalnc) as localmoney,sum(fzqywbnc) as wbmoney
  30. from CO_GB_BalanceSheet
  31. where isbook = '$(合并报表-是否包含未记账)' and iyear=$(合并报表-年度) and iperiod=$(合并报表-期间)
  32. group by iyear,iperiod,hbcompanyname,rownum,fzqyindexname
  33. ) t1 on t.iyear=t1.iyear and t.hbcompany=t1.hbcompanyname and t.biaoyang=t1.biaoyang and t.rownum=t1.rownum
  34. where t.indexname is not null
  35. order by t.biaoyang,t.rownum

《工作底稿 - 抵消调整与合并资产负债表年初》

  1. begin
  2. select t.iyear as 年度,t.iperiod as 期间,t.biaoyang as 指标类型,t.rownum as 行号,t.indexname as 指标名称,
  3. --t1.hbcompanyname,
  4. t.ordernum as 行次,sum(t1.localmoney) as 本币金额,sum(t1.wbmoney) as 外币金额
  5. into #temp_dixiaoauto000
  6. from
  7. (
  8. select *
  9. from
  10. (
  11. select distinct iyear,iperiod,hbcompany
  12. from
  13. (
  14. select distinct iyear,iperiod,companyParent as hbcompany from VW_CO_JC_Account_InvestmentParent01
  15. where 1=1 and invenstmentRatio>0 and iyear=$(合并报表-年度) and iperiod=$(合并报表-期间)
  16. union all
  17. select distinct iyear,iperiod,companyname as hbcompany from VW_CO_JC_Account_InvestmentParent01
  18. where 1=1 and invenstmentRatio>0 and iyear=$(合并报表-年度) and iperiod=$(合并报表-期间)
  19. ) as tt
  20. ) a
  21. cross join
  22. (select * from VW_CO_HB_index where biaoyang in ('A资产负债表','B资产负债表')) b
  23. )t
  24. left join
  25. (
  26. select 'A资产负债表' as biaoyang, iyear,iperiod,hbcompanyname,rownum,zcindexname as indexname,sum(zclocalnc) as localmoney,sum(zcwbnc) as wbmoney
  27. from CO_GB_BalanceSheet
  28. where isbook = '$(合并报表-是否包含未记账)' and iyear=$(合并报表-年度) and iperiod=$(合并报表-期间)
  29. group by iyear,iperiod,hbcompanyname,rownum,zcindexname
  30. union all
  31. select 'B资产负债表' as biaoyang, iyear,iperiod,hbcompanyname,rownum,fzqyindexname as indexname,sum(fzqylocalnc) as localmoney,sum(fzqywbnc) as wbmoney
  32. from CO_GB_BalanceSheet
  33. where isbook = '$(合并报表-是否包含未记账)' and iyear=$(合并报表-年度) and iperiod=$(合并报表-期间)
  34. group by iyear,iperiod,hbcompanyname,rownum,fzqyindexname
  35. ) t1 on t.iyear=t1.iyear and t.hbcompany=t1.hbcompanyname and t.biaoyang=t1.biaoyang and t.rownum=t1.rownum
  36. group by t.iyear,t.iperiod,t.biaoyang,t.rownum,t.indexname,t.ordernum,t1.iyear,t1.iperiod,t1.biaoyang
  37. select t.dxtypename as 抵消指标类型,t.rownum as 行号,
  38. t.iyear as 年度,t.iperiod as 月份,t.dxgroupname as 抵消规则,t.hbglcompany as 往来单位,
  39. t.benfangcompany as 本方单位,t.duifangcompany as 对方单位,t.indexname as 指标名称,
  40. case when t.ccodefx='借' then t.localbq else NULL end as 本币借方金额,
  41. case when t.ccodefx='贷' then t.localbq else NULL end as 本币贷方金额,
  42. case when t.ccodefx='借' then t.wbbq else NULL end as 外币借方金额,
  43. case when t.ccodefx='贷' then t.wbbq else NULL end as 外币贷方金额
  44. into #temp_dixiaoauto111
  45. from CO_DX_Auto_mx t
  46. where 1=1
  47. and tablename='资产负债表'
  48. and iyear=$(合并报表-年度)
  49. and iperiod=0
  50. and isbook = '$(合并报表-是否包含未记账)'
  51. order by t.iyear,t.iperiod,t.dxtypename,t.dxgroupname,t.hbglcompany,t.benfangcompany,t.duifangcompany
  52. select 抵消指标类型,t1.rownum as 行号,
  53. t.年度,t.月份,t.抵消规则,t.往来单位,
  54. t.本方单位,t.对方单位,t1.indexname as 指标名称,
  55. sum(t.本币借方金额*(case when t1.jsfs='加' then 1 else -1 end )) as 本币借方金额,
  56. sum(t.本币贷方金额*(case when t1.jsfs='加' then 1 else -1 end )) as 本币贷方金额,
  57. sum(t.外币借方金额*(case when t1.jsfs='加' then 1 else -1 end )) as 外币借方金额,
  58. sum(t.外币贷方金额*(case when t1.jsfs='加' then 1 else -1 end )) as 外币贷方金额
  59. into #temp_dixiaoauto222
  60. from #temp_dixiaoauto111 t
  61. inner join
  62. (
  63. select distinct dxtype,dbtype,hbcompanyname,iyear,iperiod,rownum,indexname,jsindexname,jsfs
  64. from VW_CO_JC_indexname_GS
  65. ) t1 on t.指标名称=t1.jsindexname
  66. --and t.抵消指标类型=t1.dxtype
  67. and t.年度=t1.iyear and t.月份=t1.iperiod and t.本方单位=t1.hbcompanyname
  68. group by 抵消指标类型,t1.rownum,t.年度,t.月份,t.抵消规则,t.往来单位,t.本方单位,t.对方单位,t1.indexname
  69. select SUBSTRING(indexname, 1, CHARINDEX('-', indexname) - 1) as 抵消指标类型,
  70. SUBSTRING(SUBSTRING(indexname, CHARINDEX('-', indexname) + 1, 100), 1, CHARINDEX('-', SUBSTRING(indexname, CHARINDEX('-', indexname) + 1, 100)) - 1) as 行号,
  71. iyear as 年度,iperiod as 月份,dxgroupname as 抵消规则,hbcompany as 往来单位,
  72. benfangcompany as 本方单位,duifangcompany as 对方单位,
  73. SUBSTRING(indexname, CHARINDEX('-', indexname) + CHARINDEX('-', SUBSTRING(indexname, CHARINDEX('-', indexname) + 1, 100)) + 1, 100) as 指标名称,
  74. localmoney as 本币调整金额,wbmoney as 外币调整金额
  75. into #temp_dixiaoauto333
  76. from CO_DX_Adjust
  77. where iperiod=0
  78. and SUBSTRING(indexname, 1, CHARINDEX('-', indexname) - 1)='资产负债表'
  79. and iyear=$(合并报表-年度)
  80. select 抵消指标类型,t1.rownum as 行号,
  81. t.年度,t.月份,t.抵消规则,t.往来单位,
  82. t.本方单位,t.对方单位,t1.indexname as 指标名称,
  83. sum(t.本币调整金额*(case when t1.jsfs='加' then 1 else -1 end )) as 本币调整金额,
  84. sum(t.外币调整金额*(case when t1.jsfs='加' then 1 else -1 end )) as 外币调整金额
  85. into #temp_dixiaoauto444
  86. from #temp_dixiaoauto333 t
  87. inner join
  88. (
  89. select distinct dxtype,dbtype,hbcompanyname,iyear,iperiod,rownum,indexname,jsindexname,jsfs
  90. from VW_CO_JC_indexname_GS
  91. ) t1 on t.指标名称=t1.jsindexname
  92. --and t.抵消指标类型=t1.dxtype
  93. and t.年度=t1.iyear and t.月份=t1.iperiod and t.本方单位=t1.hbcompanyname
  94. group by 抵消指标类型,t1.rownum,t.年度,t.月份,t.抵消规则,t.往来单位,t.本方单位,t.对方单位,t1.indexname
  95. select t.iyear as 年度,t.iperiod as 期间,t.biaoyang as 指标类型,
  96. t.rownum as 行号,t.indexname as 指标名称,t.ordernum as 行次,
  97. t0.本币金额 as 个别汇总本币金额,t0.外币金额 as 个别汇总外币金额,
  98. t1.本币借方金额 as 本币借方金额,t1.本币贷方金额 as 本币贷方金额,
  99. t1.外币借方金额 as 外币借方金额,t1.外币贷方金额 as 外币贷方金额,
  100. t2.本币调整金额 as 本币调整金额,t2.外币调整金额 as 外币调整金额,
  101. t0.本币金额-isnull(t1.本币借方金额,0)-isnull(t1.本币贷方金额,0)-isnull(t2.本币调整金额,0) as 合并本币金额,
  102. t0.外币金额-isnull(t1.外币借方金额,0)-isnull(t1.外币贷方金额,0)-isnull(t2.外币调整金额,0) as 合并外币金额
  103. from
  104. (
  105. select *
  106. from
  107. (select $(合并报表-年度) as iyear,$(合并报表-期间) as iperiod) a
  108. cross join (select * from VW_CO_HB_index where biaoyang in ('A资产负债表','B资产负债表')) b
  109. )t
  110. left join #temp_dixiaoauto000 as t0
  111. on t.iyear=t0.年度 and t.iperiod=t0.期间 and t.rownum=t0.行号 and t.indexname=t0.指标名称 and t.biaoyang=t0.指标类型
  112. left join
  113. (
  114. select t.年度 as 年度,t.月份 as 期间,t.行号 as 行号,t.指标名称,
  115. sum(本币借方金额) as 本币借方金额,
  116. sum(本币贷方金额) as 本币贷方金额,
  117. sum(外币借方金额) as 外币借方金额,
  118. sum(外币贷方金额) as 外币贷方金额
  119. from
  120. (
  121. select * from #temp_dixiaoauto111
  122. union all
  123. select * from #temp_dixiaoauto222
  124. )t
  125. group by t.年度,t.月份,t.行号,t.指标名称
  126. ) t1 on t.iyear=t1.年度 and t.rownum=t1.行号 and t.indexname=t1.指标名称
  127. left join
  128. (
  129. select t.年度 as 年度,t.月份 as 期间,t.行号 as 行号,t.指标名称,
  130. sum(本币调整金额) as 本币调整金额,
  131. sum(外币调整金额) as 外币调整金额
  132. from
  133. (
  134. select * from #temp_dixiaoauto333
  135. union all
  136. select * from #temp_dixiaoauto444
  137. )t
  138. group by t.年度,t.月份,t.行号,t.指标名称
  139. ) t2 on t.iyear=t2.年度 and t.rownum=t2.行号 and t.indexname=t2.指标名称
  140. where 1=1 and t.indexname is not null
  141. order by t.biaoyang,t.rownum
  142. drop table #temp_dixiaoauto000;
  143. drop table #temp_dixiaoauto111;
  144. drop table #temp_dixiaoauto222;
  145. drop table #temp_dixiaoauto333;
  146. drop table #temp_dixiaoauto444;
  147. end