I have a requirement to change the structure of Product Hierarchy Bigquery table as below: This should be done using Bigquery SQL
Current Table:
salesorg | distr_chan | material | hier_lvl | prod_hier | txt |
---|---|---|---|---|---|
PH01 | 20 | 680483 | prodh1 | PH | Philippines |
PH01 | 20 | 680483 | prodh2 | PHGR | Grocery |
PH01 | 20 | 680483 | prodh3 | PHGRGR | Grocery |
PH01 | 20 | 680483 | prodh4 | PHGRGR731 | Eden Mayo |
PH01 | 20 | 680483 | prodh5 | PHGRGR731Q27 | Eden Mayo |
PH01 | 20 | 680483 | prodh6 | PHGRGR731Q27P410 | Sandwich Spread |
PH01 | 20 | 680483 | prodh7 | PHGRGR731Q27P410PI | Bottle |
Required Table
salesorg | distr_chan | material | prodh1 | prodh2 | prodh3 | prodh4 | prodh5 | prodh6 | prodh7 | prodh1txt | prodh2txt | prodh3txt | prodh4txt | prodh5txt | prodh6txt | prodh7txt |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PH01 | 20 | 680483 | PH | PHGR | PHGRGR | PHGRGR731 | PHGRGR731Q27 | PHGRGR731Q27P410 | PHGRGR731Q27P410PI | Philippines | Grocery | Grocery | Eden Mayo | Eden Mayo | Sandwich Spread | Bottle |
Is there a way to achieve this ?