select sum(GBAPYC/100) 年初数,sum(GBAN/100) 月份数合计,sum(GBAPYC/100+GBAN/100) 期末数,trim(GBOBJ) GBOBJ from (select GBAPYC,GBOBJ,GBAID,GBCTRY,GBFY,GBCO,GBAN01 GBAN, 1 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBAID,GBCTRY,GBFY,GBCO,GBAN02 GBAN, 2 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBAID,GBCTRY,GBFY,GBCO,GBAN03 GBAN, 3 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBAID,GBCTRY,GBFY,GBCO,GBAN04 GBAN, 4 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBAID,GBCTRY,GBFY,GBCO,GBAN05 GBAN, 5 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBAID,GBCTRY,GBFY,GBCO,GBAN06 GBAN, 6 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBAID,GBCTRY,GBFY,GBCO,GBAN07 GBAN, 7 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBAID,GBCTRY,GBFY,GBCO,GBAN08 GBAN, 8 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBAID,GBCTRY,GBFY,GBCO,GBAN09 GBAN, 9 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBAID,GBCTRY,GBFY,GBCO,GBAN10 GBAN, 10 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBAID,GBCTRY,GBFY,GBCO,GBAN11 GBAN, 11 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBAID,GBCTRY,GBFY,GBCO,GBAN12 GBAN, 12 m FROM proddta.f0902)where GBCTRY = '${GBCTRY}' and GBFY = '${GBFY}' and GBCO = '${GBCO}'and m<='${GBAN}'and GBOBJ = '1001' or GBOBJ = '1002' OR GBOBJ = '1012' group by trim(GBOBJ)order by 4年初数是固定的,期末数=年初数+月份数合计 如果是1月就 年初数+1月份数据如果是2月, 年初数+1月份数据+2月份数据累加的时候,貌似加重复了,请问如何改一下