时间:2021-07-01 10:21:17 帮助过:19人阅读
1 select max(xzqmc2) qymc,0 as hzbs, 2 sum(mjm) as bhmj, 3 count(sfcl) as bhs, 4 sum(case when sfcl=‘是‘then 1 else 0 end) ycltbs , 5 sum(case when sfcl=‘是‘then mjm else 0 end) ycltbmj, 6 sum(case when sfcl=‘否‘then 1 else 0 end) wcltbs , 7 sum(case when sfcl=‘否‘then mjm else 0 end) wcltbmj 8 from zz_ygyswftb where pcsid = #{pcid} group by xzqmc2 9 union 10 select ‘萍乡‘ qymc,1 as hzbs, 11 sum(mjm) as bhmj, 12 count(sfcl) as bhs, 13 sum(case when sfcl=‘是‘then 1 else 0 end) ycltbs , 14 sum(case when sfcl=‘是‘then mjm else 0 end) ycltbmj, 15 sum(case when sfcl=‘否‘then 1 else 0 end) wcltbs , 16 sum(case when sfcl=‘否‘then mjm else 0 end) wcltbmj 17 from zz_ygyswftb where pcsid = #{pcid}
sql group by sum
标签:分区 rgb ase 技术 sql case when where lazy 根据