I have a table like below:
And, I want the field values as col headers like below:
I tried using PIVOT function of bigQuery but that didn't work. Can anyone guide me on how to achieve this? Thanks
CodePudding user response:
Pivot is the appropriate function to use in this case. Try the following:
select *
from (select * except(field_id) from sample_data)
pivot (max(field_value) for field in ('name', 'age', 'gender', 'email', 'contact', 'address', 'state', 'city'))
It produces