如何将mysql行以简单的方式转换为列
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何将mysql行以简单的方式转换为列相关的知识,希望对你有一定的参考价值。
答案
您可以使用条件聚合:
select id,
avg(case when semester = 20081 then IP_Semester end) as sem_20081,
avg(case when semester = 20082 then IP_Semester end) as sem_20082,
. . .
from t
group by id;
以上是关于如何将mysql行以简单的方式转换为列的主要内容,如果未能解决你的问题,请参考以下文章