Skip to content
Advertisement

String Aggregtion to create pivot columns in Big Query

I am trying to implement this exact solution linked below, but it seems GROUP_CONCAT_UNQUOTED is no longer a valid BQ function. Is there a solution to this that works in 2020?

p.s. I would have just commented on the original post, but apparently my reputation isn’t high enough yet…

Transpose rows into columns in BigQuery (Pivot implementation)

Advertisement

Answer

Below example is for BigQuery Standard SQL

Assume you have data as below

to get those keys pivoted – you can use below query

with result

to make your life simpler and not to type all those line for each and every key – you can instead generate the whole SQL text using below query

Note: the post you mentioned in your question was given in 2016 and for Legacy SQL

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement