Tuesday, February 25, 2014

selecting table columns as table rows

This would also give you required results



SELECT t.company,
t.account,
t1.PeriodID,
t1.PeriodVal AS amount
FROM TableName t
CROSS APPLY (VALUES(1,PERIOD1),
(2,PERIOD2),
(3,PERIOD3),
(4,PERIOD4),
(5,PERIOD5),
(6,PERIOD6),
(7,PERIOD7),
(8,PERIOD8),
(9,PERIOD9),
(10,PERIOD10),
(11,PERIOD11),
(12,PERIOD12)
)t1(PeriodID,Period)





Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


No comments:

Post a Comment