select ID,TERM,score as china from cloud2012 where subject='china'
union all
select ID,TERM,score as math from cloud2012 where subject='math'
union all
select ID,TERM,score as english from cloud2012 where subject='english'
请问怎么行列合并,我想使用这种方法进行行列转换。
在存储过程中如何写转换的SQL。
union all
select ID,TERM,score as math from cloud2012 where subject='math'
union all
select ID,TERM,score as english from cloud2012 where subject='english'
请问怎么行列合并,我想使用这种方法进行行列转换。
在存储过程中如何写转换的SQL。
--mssql
select ID,TERM,max(case when subject='china' then score end) as china,
max(case when subject='math' then score end) as math,
max(case when subject='english' then score end) as english
from cloud2012 group by ID,TERM