question

SQL_Learner avatar image
SQL_Learner asked

Unpivot query error

I have a table with numbers stored in monthly columns and I wan to unpivot them all.

But I am Getting error SQL Error [500310] [42601]: [Amazon](500310) Invalid operation: syntax error at or near "UNPIVOT" Position: 139; while running below query

SELECT vendor_id, Months, trx FROM ( SELECT vendor_id, [trx_jan], [trx_feb] FROM PUBLIC.trx_table ) As sbm UNPIVOT (trx FOR Months IN ([trx_jan], [trx_feb]) )AS SalesUnPivot;

sql
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ThomasRushton avatar image ThomasRushton ♦♦ commented ·

Looks OK from here, apart from "PUBLIC" - try wrapping that in square brackets...

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.