--Create Tablecreate table student (name varchar, course varchar (), score int) insert into student values (' Three ', ' language ', 80) INSERT into student values (' Three ', ' math ', ' student ') insert into the values (' three ', ' physical ', ') insert into student values (' John Doe ', ' language ', 73 INSERT into student values (' John Doe ', ' math ', "") insert into student values (' John Doe ', ' physical ', 95)--row-and-column and insert into temporary table Rtcselect Name,max (Case c Ourse when ' language ' then score else 0 end as language, Max (case course when ' math ' then score else 0 end) as math, max (case course when ' physics ' Then score else 0 end ' as physical into RTC from student GROUP by NameSelect * from RTC--RTC for the original table column select * FROM (select name , ' language ' course, text as score from Rtcunionselect name, ' Mathematics ' course, mathematics as score from Rtcunionselect name, ' physical ' course, physical as score From RTC) a ORDER BY 1 desc
SQL row column columns are changed