hadoophivehortonworks-data-platformhortonworks-dataflow

Transpose in HIVE SQL


I am trying to transpose like below.

clm_nb                              part_nb 
008195066                           20401
008195066                           20411
008195179                           89598
008195179                           89599
008195277                           56478
008195277                           56477

clm_nb                              part_nb                part_nb
008195066                           20401                    20411
008195179                           89598                    89599
008195277                           56477                    56477

Solution

  • looking to your data seems you need in in the first column max in the second eg:

      select clm_nb ,  min(part_nb) min_part, max(part_nb) max_part
      from my_table 
      group by  clm_nb