select gbco,cast(GBSBL as int) JDE,rtrim(wwgnnm)+' '+ltrim(wwsrnm) OwnerName,sum(gbapyc+GBAN01)/100 "07_01",sum(gbapyc+GBAN01+GBAN02)/100 "07_02", sum(gbapyc+GBAN01+GBAN02+GBAN03)/100 "07_03" , sum(gbapyc+GBAN01+GBAN02+GBAN03+GBAN04)/100 "07_04" , sum(gbapyc+GBAN01+GBAN02+GBAN03+GBAN04+gban05)/100 "07_05" , sum(gbapyc+GBAN01+GBAN02+GBAN03+GBAN04+gban05+gban06)/100 "07_06" , sum(gbapyc+GBAN01+GBAN02+GBAN03+GBAN04+gban05+gban06+gban07)/100 "07_07" , sum(gbapyc+GBAN01+GBAN02+GBAN03+GBAN04+gban05+gban06+gban07+gban08)/100 "07_08" , sum(gbapyc+GBAN01+GBAN02+GBAN03+GBAN04+gban05+gban06+gban07+gban08+gban09)/100 "07_09" , sum(gbapyc+GBAN01+GBAN02+GBAN03+GBAN04+gban05+gban06+gban07+gban08+gban09+gban10)/100 "07_10" , sum(gbapyc+GBAN01+GBAN02+GBAN03+GBAN04+gban05+gban06+gban07+gban08+gban09+gban10+gban11)/100 "07_11" , sum(gbapyc+GBAN01+GBAN02+GBAN03+GBAN04+gban05+gban06+gban07+gban08+gban09+gban10+gban11+gban12)/100 "07_12", sum(gbapyc+GBAN01+GBAN02+GBAN03+GBAN04+gban05+gban06+gban07+gban08+gban09+gban10+gban11+gban12+gban13)/100 "07_13" from proddta.f0902 left outer join proddta.f0111 on cast(GBSBL as int)=wwan8 where gbfy=7 and GBAID in (33333,44444,5555,555555) and GBLT='AA' and gbsblt='A'group by cast(GBSBL as int),gbco,wwgnnm,wwsrnm,gbfy, GBAIDorder by gbco,cast(GBSBL as int)
No comments:
Post a Comment