|
|
SQL code
-- TEST DATA: Name Curricula Mark 张三 语文 70 李四 数学 80 王朝 英语 59 城南 马哲 70 王朝 语文 90 -- SQL: select sn, max ( case when Curricula = ' 语文 ' then name end ) 语文, max ( case when Curricula = ' 数学 ' then name end ) 数学, max ( case when Curricula = ' 英语 ' then name end ) 英语, max ( case when Curricula = ' 马哲 ' then name end ) 马哲 from ( select name,curricula,mark, row_number() over (partition by curricula order by name) sn from t where mark > 59 ) group by sn -- RESULT: 语文 数学 英语 马哲 1 张三 李四 城南 2 王朝