hive sql樅表橫表互相轉換

樅錶轉橫表

select 
        product_id
        ,max(case when field='test1' then 1 else 0 end) as test1
        ,max(case when field='test2' then 1 else 0 end) as test2
        ,max(case when field='test2' then 1 else 0 end) as test2
from 
    test_table_name
group by id

橫錶轉樅表

主要是explode、split、concat_ws等方法組合使用
https://www.cnblogs.com/foolangirl/p/14145147.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章