日期:2014-05-18  浏览次数:20422 次

询问在一个表中按编号组合数据的问题
在一个A表中有如下数据

ID title Text  
1 taa aa
1 tbb bb
1 tcc cc
2 tdd dd
2 tee ee
2 tff ff

我想实现如下新表
ID taa tbb tcc 
1 aa bb cc  
2 dd ee ff
 
是否可以实现?如何实现?


------解决方案--------------------
select 
id,
taa=max(case when title='taa' then text end),
tbb=max(case when title='tbb' then text end),
tcc=max(case when title='tcc' then text end)
from [A]
group by id