https://blog.csdn.net/weixin_45488228/article/details/104480537

SELECT 
   case when abitmap=0 then ''
        when abitmap=1 then ''
        else ''
   end as bitmap 
from userinfo

记得别忘了END

select aaa.aName
, sum( case aaa.aMonth when 1 then aaa.aProductSum end ) as '一月' 
, sum( case aaa.aMonth when 2 then aaa.aProductSum end ) as '二月' 
, sum( case aaa.aMonth when 3 then aaa.aProductSum end ) as '三月' 
, sum( case aaa.aMonth when 4 then aaa.aProductSum end ) as '四月' 
, sum( case aaa.aMonth when 5 then aaa.aProductSum end ) as '五月' 
, sum( case aaa.aMonth when 6 then aaa.aProductSum end ) as '六月' 
, sum( case aaa.aMonth when 7 then aaa.aProductSum end ) as '七月' 
 from aaa
GROUP BY aaa.aName

 相当于Excel里的数据透视表  功能