Monday, April 28, 2014

PIVOT and UNPIVOT


create table test (QTY int, AMT int)
insert into test values (1,2),(1,1),(2,2)


select MeasureCode,Measure from (select * from test) src
cross apply (values(QTY,'QTY'), (AMT,'AMT')) d(Measure,MeasureCode)



drop table test


No comments:

Post a Comment