select sum(GBAPYC/100), --年初数,sum(GBAN/100), --月份数合计,sum(GBAPYC/100+GBAN/100), --期末数,trim(GBOBJ)||trim(GBSUB) GBOBJGBSUB--trim(GBOBJ)||trim(GBSUB)from (select GBAPYC,GBOBJ,GBSUB,GBAID,GBCTRY,GBFY,GBCO,GBAN01 GBAN, 1 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBSUB,GBAID,GBCTRY,GBFY,GBCO,GBAN02 GBAN, 2 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBSUB,GBAID,GBCTRY,GBFY,GBCO,GBAN03 GBAN, 3 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBSUB,GBAID,GBCTRY,GBFY,GBCO,GBAN04 GBAN, 4 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBSUB,GBAID,GBCTRY,GBFY,GBCO,GBAN05 GBAN, 5 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBSUB,GBAID,GBCTRY,GBFY,GBCO,GBAN06 GBAN, 6 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBSUB,GBAID,GBCTRY,GBFY,GBCO,GBAN07 GBAN, 7 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBSUB,GBAID,GBCTRY,GBFY,GBCO,GBAN08 GBAN, 8 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBSUB,GBAID,GBCTRY,GBFY,GBCO,GBAN09 GBAN, 9 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBSUB,GBAID,GBCTRY,GBFY,GBCO,GBAN10 GBAN, 10 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBSUB,GBAID,GBCTRY,GBFY,GBCO,GBAN11 GBAN, 11 m FROM proddta.f0902union allselect 0 GBAPYC,GBOBJ,GBSUB,GBAID,GBCTRY,GBFY,GBCO,GBAN12 GBAN, 12 m FROM proddta.f0902)where GBCTRY = '${GBCTRY}' and GBFY = '${GBFY}' and GBCO = '${GBCO}'and m<='${GBAN}' --group by trim(GBOBJ)order by 4