if object_id('grade')is not null drop table grade
go
create table grade(姓名 varchar(10),课程 varchar(10),分数 int)
insert into grade values('张三','语文',74)
insert into grade values('张三','数学',83)
insert into grade values('张三','物理',93)
insert into grade values('李四','语文',74)
insert into grade values('李四','数学',84)
insert into grade values('李四','物理',94)
go
select * from grade
select * from grade pivot(max(分数) for 课程 in (语文,数学,物理))a