I have a table like this: table1:
month pool_name apy
------------------------------
04-2021 a 1
04-2021 c 2
04-2021 d 1
04-2021 f 3
04-2021 g 5
04-2021 h 6
05-2021 a 2
05-2021 b 3
05-2021 c 2
05-2021 e 7
05-2021 f 5
05-2021 h 6
05-2021 i 4
.
.
.
how can I transpose or pivot (actully I don't know about that) the table1 to table2:
month a b c d e f g h i
----------------------------------------------------
04-2021 1 0 2 1 0 3 5 6 0
05-2021 2 3 2 0 7 5 0 6 4
I use this code but I have an error.
select month,pool_name,apy from table1
pivot (sum(apy) for pool_name in (select distinct(pool_name) from table1))
I have to write this code in snowflake (classic web interface). Thank you in advance.