首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

关于mysql的行转列有关问题

2012-10-30 
关于mysql的行转列问题一张表,里面有? id? name?? state??? customerid 4个字段,其中status有3个值0 1 2 ,

关于mysql的行转列问题

一张表,里面有? id? name?? state??? customerid 4个字段,其中status有3个值0 1 2 ,用一条sql查询出此种格式

select customid,      count(case status when 0 then status else null end) as status-0,      count(case status when 1 then status else null end) as status-1,      count(case status when 2 then status else null end) as status-2      from custom group by customid.  
?

?

热点排行