I have a table named Forecast as below:
Product_BK has about 80,000 records, while the Month has 12. The States remain static at 5.
How can I write a qu
You can use SQL Server's built-in UNPIVOT function:
SELECT PRODUCT_BK, Month, State, Forecast FROM (SELECT * FROM Forecast_Table) t UNPIVOT (Forecast FOR State IN (SA_NT, QLD, VIC_TAS, WA, NSW_ACT)) AS fcst