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

posted @   致林  阅读(322)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示