Sample Query for Unpivoting data:
Table Structure:
------------------------------------------------------------------------------------------------------
AccountNo AccountKey Datekey PeriodID Segment 1 Segment 2 Segment 3 Debit Credit
------------------------------------------------------------------------------------------------------
1 1 234 12 456 567 346 3423 44353
-----------------------------------------------------------------------------------------------------
SELECT AccountNo, AccountKey, Datekey, PeriodID, Debit, Credit
FROM
(
SELECT AccountKey, Datekey, PeriodID, Credit,
[Segment 1] As Segment1, [Segment 2] As Segment2, [Segment 3] As Segment3
FROM dbo.vw_FactAccount
) MyTable
UNPIVOT
(Debit FOR Accountno IN (Segment1, Segment2, Segment3))AS MyUnPivot
Result
----------------------------------------------------------------------------------------------
AccountNo AccountKey DateKey PeriodID Debit Credit
-----------------------------------------------------------------------------------------------
Segment1 1 234 12 3423 44353
Segment2 1 234 12 3423 44353
Segment3 1 234 12 3423 44353
------------------------------------------------------------------------------------------