T1
T2 result from unpivot T1
Unpivot query:
SELECT LocM, convert(varchar,[Date],112) as DateKey, FinanceCode, Amount
FROM SalesDetail
UNPIVOT
([Amount] FOR [FinanceCode] IN([Sales],[Wages])) AS P
T3
How to join/merge T2 with T3 so the result will be like:
StoreCode | FinanceCode | DateKey | Amount
070 | Wages | 20160131 | 3533
070 | Sales | 20160131 | 833
070 | 0000 | 20160131 | 0


