Hi All! I have a simple sales table that looks like this:
ORDER_NUM SKU MONTH
50412355 T300 1
50412356 T300 1
50412357 T310 2
50412358 R310 4
50412359 Z566 2
I'm using the PIVOT function to pivot the table:
SELECT * FROM
(SELECT [SKU], [MONTH] FROM SALES_TABLE) AS T1
PIVOT
(COUNT([MONTH]) FOR [MONTH] IN ([1], [2], [3], [4], [5], [6], [7])
) AS P1
Suppose there's hundreds of unique values within the Month column.
Is there a way to write the code so that I don't have to specify ALL the values within the month. FOR MONTH IN ([[1], [2] ...
Instead, it can do something like FOR MONTH IN (*)
?
Thanks!