Row & Column Swap Template

less than 1 minute read

Row_Column_Swap_Template

image

select A,
-- 第2步,在行列互换结果表中,其他列里的值分别使用case和max来获取
max(case B when 'm' then C else 0 end) as 'm',
max(case B when 'n' then C else 0 end) as 'n'
from cook
-- 第1步,在行列互换结果表中按第1列分组
group by A;

Tags:

Categories:

Updated: