user11912471
user11912471

Reputation:

SQL BigQuery Rows to column

This is a sample of my data

enter image description here

I am trying to get :

enter image description here

Thank you

Upvotes: 0

Views: 59

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269493

You can unpivot in BigQuery using unnest() and arrays:

select t.holiday, t.segment, el.dte, el.booking
from t cross join
     unnest(array[struct('1/1/2020' as dte, "1/1/2020" as booking),
                  struct('1/2/2020' as dte, "1/2/2020" as booking),
                  . . .
                 ]
            ) el;

Upvotes: 2

Related Questions