22,209
社区成员
发帖
与我相关
我的任务
分享
select max(case when x = 1 then y end) as a1,
max(case when x = 2 then y end) as a2,
max(case when x = 3 then y end) as a3,
max(case when x = 4 then y end) as a4
from
(
select 1 as x ,'a' as y union all
select 2 ,'b' union all
select 3 ,'c' union all
select 4 ,'d'
)v
/*
a1 a2 a3 a4
a b c d
*/