更新时间:2023-11-18 21:58:58
您可以使用 row_number()
&做聚合:
You can use row_number()
& do aggregation :
select User,
max(case when seq = 1 then role end) as a,
max(case when seq = 2 then role end) as b,
max(case when seq = 3 then role end) as c
from (select t.*,
row_number() over (partition by User order by group) as seq
from table t
) t
group by User;