测试数据
name | course | score |
---|---|---|
Darren | Chinese | 71 |
Darren | Math | 81 |
Darren | English | 91 |
Jonathan | Chinese | 72 |
Jonathan | Math | 82 |
Jonathan | English | 92 |
Tom | Chinese | 73 |
行转列
语法
SELECT
xxx
FROM
table_test
PIVOT(
聚合函数(value_column) FOR pivot_column in (<column_list>)
)
Example:
SELECT
*
FROM row_table
PIVOT(
MAX(score) FOR course in ('Chinese', 'Math', 'English')
)
结果:
name | Chine |
---|