Hive Sql 行转多列实际案例
1、行转多列实际案例
1 SELECT MR_Longitude,MR_Latitude,b,MAX(a) FROM 2 ( 3 select a,b, 4 MR_Longitude * 360 *1.0/ 16777216 MR_Longitude, 5 MR_Latitude * 90 / 8388608 MR_Latitude 6 FROM etl_4g_mro_zte 7 lateral view explode( 8 split(concat_ws(',',MR_LteScRSRP,MR_LteNcRSRP1,MR_LteNcRSRP2,MR_LteNcRSRP3,MR_LteNcRSRP4,MR_LteNcRSRP5),','))r1 AS a -----没有',' 9 lateral view explode( 10 split(concat_ws(',',MR_LteScEarfcn,MR_LteNcEarfcn1,MR_LteNcEarfcn2,MR_LteNcEarfcn3,MR_LteNcEarfcn4,MR_LteNcEarfcn5),',')) f1 as b 11 12 WHERE MR_Longitude IS NOT NULL 13 AND MR_Longitude <>'' 14 AND DAY=20170323
注: 行转多列可以认为多列是一个字段处理,多个转换之间不能有 "," 分割开