合并行 number/primary 键相同的列

Combining columns where row number/primary key is the same

我创建了一个临时 table,其中包含一个 student_id 和三个对应于 student_id 的值,但是由于我编写脚本的方式,student_id出现三次而不是一次,在这里你可以看到我的意思的图片。

假设第一个 table 被命名为 #temp_results,我可以使用什么 sql 代码将其转换为第二个图片。

它主要用于快速概览,因此如果将其保存在不同的临时文件中就可以了 table。

我现在拥有的

我希望它成为什么

您需要汇总:

select student_id, max(phase1), max(phase2), max(phase3)
from #temp_results t
group by student_id;