Unable to pivot multiple columns in snowflake.
This works:
--DROP TABLE "PUBLIC".MONTHLY_SALES
create or replace table monthly_sales(empid int, amount int, month text)
as select * from values
(1, 10000, 'JAN'),
(1, 400, 'JAN'),
(2, 4500, 'JAN'),
(2, 35000, 'JAN'),
(1, 5000, 'FEB'),
(1, 3000, 'FEB'),
(2, 200, 'FEB'),
(2, 90500, 'FEB'),
(1, 6000, 'MAR'),
(1, 5000, 'MAR'),
(2, 2500, 'MAR'),
(2, 9500, 'MAR'),
(1, 8000, 'APR'),
(1, 10000, 'APR'),
(2, 800, 'APR'),
(2, 4500, 'APR');
SELECT * FROM monthly_sales
pivot(
sum(amount)
for month in ('JAN', 'FEB', 'MAR', 'APR')
) AS p;
But I receive an error when adding an additional aggregate
SELECT * FROM monthly_sales
pivot(
sum(amount)
, count(amount)
for month in ('JAN', 'FEB', 'MAR', 'APR')
) AS p;
QL Error [1003] [42000]: SQL compilation error: syntax error line 4 at position 5 unexpected ','. syntax error line 4 at position 12 unexpected '('. syntax error line 5 at position 45 unexpected ')'.
Any guidance is appreciated