MYSQL 行转列

SELECT 
`name`,
max( case `course` when '语文' then grade else 0 end) as 语文,
max( case `course` when '数学' then grade else 0 end) as 数学,
max( case `course` when '英语' then grade else 0 end) as 英语 
FROM table_a group by `name`

 

posted @ 2021-07-22 11:47  谷仁儿  阅读(53)  评论(0编辑  收藏  举报