You can do this using case statements and summing the values. The only item to 
remember here is that the values in the grid need to be numeric for the sum to 
work.

Thanks,
Ranjith

From: richin.j...@nokia.com [mailto:richin.j...@nokia.com]
Sent: Tuesday, August 07, 2012 3:58 PM
To: user@hive.apache.org
Subject: Converting rows into dynamic colums in Hive

Hi All,

One of my Query output looks like-

Alpha                    Beta                       Gamma
123                         xyz                         1.0
123                         abc                         0.5
123                         pqr                         1.3
123                         def                         2.1
456                         xyz                         0.1
456                         abc                         0.6
456                         pqr                         1.9
456                         def                         3.2
456                         lmn                        1.1
456                         sdf                          1.2

I want the output for the data visualization purpose to look like (basically 
taking rows from one table and making it column in another table)

Alpha                    xyz         abc         pqr         def         lmn    
    sdf
123                         1.0          0.5          1.3          2.1
456                         0.1          0.6          1.9          3.2          
1.1          1.2

Question - Can it be done in Hive? If not, any suggestions.

Thanks,
Richin


Reply via email to