数据是sql server 或者mysql ,求一个转换,具体如图,谢谢。
SELECT *
FROM student
PIVOT (
SUM(score) FOR subject IN (语文, 数学, 英语)
)
SELECT *
FROM student1
UNPIVOT (
score FOR subject IN ("语文","数学","英语")
)
select t1.a1,t1.c1 as w,t2.c1 as b from (select a1,c1 from 原表 where b1='w') t1 left join (select a1,c1 from 原表 where b1='b') t2 on t1.a1=t2.a1;