select bmdm,bmmc,sum(je) as je1,0 as je2 ,0 as je3,0 as je4 from gz_gzmxb where gsdm='001001' and ffcs='11' and lbdm='01' and ffnd='2016' and gzdm='99' and mxxmdm='1' group by bmdm,bmmc union select bmdm,bmmc,0 as je1,sum(je) as je2 ,0 as je3,0 as je4 from gz_gzmxb where gsdm='001001' and ffcs='11' and lbdm='01' and ffnd='2016' and gzdm='99' and mxxmdm='2' group by bmdm,bmmc union select bmdm,bmmc,0 as je1,0 as je2 ,sum(je) as je3,0 as je4 from gz_gzmxb where gsdm='001001' and ffcs='11' and lbdm='01' and ffnd='2016' and gzdm='99' group by bmdm,bmmc union select bmdm,bmmc,0 as je1,0 as je2 ,0 as je3,sum(SDS) as je4 from gz_gzmxb where gsdm='001001' and ffcs='11' and lbdm='01' and ffnd='2016' and gzdm='99' group by bmdm,bmmc