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
Post a Comment