create table #tb(name varchar(32),kechen varchar(32),score float);insert into #tb values('小明','数学',99)insert into #tb values('小明','英语',60)insert into #tb values('小明','语文',100)insert into #tb values('小强','数学',29)insert into #tb values('小强','语文',130) --行转列select * from #tb pivot(sum(score)for kechen in([数学],[英语],[语文]))a--列转行select * from #tb1 unpivot(score for kechen in ([数学],[英语],[语文])) a
300字范文,内容丰富有趣,生活中的好帮手!