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

注: 行轉多列可以認為多列是一個字段處理,多個轉換之間不能有 "," 分割開


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM