NeroCube / bookmark

Place some learning resources
0 stars 0 forks source link

Bigquery Pivot #398

Open NeroCube opened 1 year ago

NeroCube commented 1 year ago

WITH keys AS (
  SELECT DISTINCT l_key
  FROM your_table
)
SELECT *
FROM (
  SELECT id, l_key, l_value
  FROM your_table
)
PIVOT (
  MAX(l_value) FOR l_key IN (
    SELECT STRING_AGG(l_key, ',') FROM keys
  )
)