日期:2014-05-19  浏览次数:20587 次

简单的列转行
id   num
01   17
01   22

id仅限2个


想得到如下结果:
01   17   22
或者
01   22   17


------解决方案--------------------
select id,max(case num when 17 then 17 else 0 end),max(case num when 22 then 22 else 0 end) from table1 group by id