Example of pivot query

SELECT openyear, actnumst, actdescr, accountcategory, isnull([1],0) as [1], [2], [3], [4],[5],[6],[7],[8],[9],[10],[11],[12]

FROM

(SELECT openyear, actnumst, actdescr,accountcategory, periodid, Periodbalance FROM vwGeneralLedgerTotals_CurrentYear) p

PIVOT (sum(periodbalance) FOR periodid IN ([1], [2], [3],[4],[5],[6],[7],[8],[9],[10],[11],[12])) AS pvt

order by openyear, accountcategory