The Vertica Forum recently got a makeover! Let us know what you think by filling out this short, anonymous survey.

dynamic Pivot or Transpose

Hi,

 

I have a dataset like the following;

 

groupidtime_stampconsumption
A1201501X1
A1201503X2
A1201505X3
A1201506X4
B1201502X5
B1201503X6
B1201505X7
B1201506X8
B1201507X9

 

 

and I would like to convert the dataset to

 

groupidT_201501T_201502T_201503T_201505T_201506T_201507
A1X1 X2X3X4 
B1 X5X6X7X8X9

 

max(decode) works perfectly, I can pivot the table as desired.

 

But the problem is in our dataset we have 144 distinct "time_stamp"s, which means we need to write max(code) statement 144 times.

 

Is there a way we can dynamically populate the max(decode) lines and pivot or transpose the table.

 

Thanks

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.