pandas - How to Transpose table in redshift? -


is there better way, transpose table in redshift, other taking out in pandas , getting things done.

you can try using below query. below query helpful, if number of rows per group constant value

select col1,         split_part(col_values, ',', 1) col_value1,         split_part(col_values, ',', 2) col_value2,         split_part(col_values, ',', 3) col_value3   (select col1,                listagg(col2, ',')                  within group (order col2) col_values           (select col1,                        col2                   table1) derived_table1        group  col1) derived_table2 

note: above query used if have same number of rows per group or if know maximum number of rows per group.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -