2 dengshanhaihai dengshanhaihai 于 2014.10.31 11:18 提问

将两条sql合并为一个,即为 select .. K19,... L19 这样语句?在线等大牛帮忙
sql

1.select sum(a.aaa) as K19 from a where ((a.bbb = '1')
2.select sum(a.aaa) as L19 from a where ((a.bbb = '2')

1个回答

tangxiaochun
tangxiaochun   2014.10.31 15:08

select sum(case when a.bbb='1' then a.aaa else 0 end) as K19,sum(case when a.bbb='2' then a.aaa else 0 end) as L19 from a;

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!