0

I was trying to convert rows to columns - and was not able to achieve - here is my data set - table1

Zipcode  dcode dname 
009      512   Albany
009      513   springfield
008      123   place1
008      123   place1
007      345   place2
007      346   place3

I want the data to be converted as

Zipcode dcode1 dcode2 dname1 dname2
009      512     513   Albany Springfield 
008      123           place1 
007      345     346   place2 place3

  • Do you know how many distinct `dcode` and `dname` values you have? And are those #s likely to increase over time? – rtenha Jun 09 '20 at 17:59

1 Answers1

0

Pivoting in BigQuery is not yet supported. The BigQuery Engineering team is aware of this missing feature and is working as fast as they can and you can track their progress via this Public Issue Tracker (also known as "PIT").

No worries, the community has found some ways to achieve this. Take a look at this interesting public blog where you will find multiple approaches and examples of each of pivot in BigQuery. On that blog this other StackOverflow question is mentioned.

You will see that this feature has been requested since a long time but for now we don't know exactly when to expect it and for that reason I would suggest to follow the PIT for further updates.

Hope this is helpful!

Kevin Quinzel
  • 1,430
  • 1
  • 13
  • 23