--建表 create table row2col1( col1 string, col2 string, col3 int ) row format delimited fields terminated by '\t';
--加载数据到表中 load data local inpath '/export/data/r2c1.txt' into table row2col1;
2 实现
SQL实现转换
select col1 as col1, max(case col2 when 'c' then col3 else 0 end) as c, max(case col2 when 'd' then col3 else 0 end) as d, max(case col2 when 'e' then col3 else 0 end) as e from row2col1 group by col1;