So I can't figure out how to get tables to pivot in Snowflake. I'm trying to model the help page here https://docs.snowflake.com/en/sql-reference/constructs/pivot.html.
In this example, I'm only pulling 3 columns, the step, the parameter being measured and the value. Trying to pivot it so each parameter is in its own column.
source output
step_name Parameter_Name Value
----------------------------------
A Item1 75
A Item2 32
B Item1 45
B Item2 62
pivot output
step_name Item1 Item2
--------------------------
A 75 32
B 45 62
sql text:
select
step_name,
PARAMETER_NAME,
Value
from "METRO_TABLE"
pivot (avg(Value) for PARAMETER_NAME in ('Item1', 'Item2'))
as p
WHERE
and PARAMETER_NAME in ('Item1','Item2')
limit 50