Not a brilliant way but this is a way...
drop table temp5
SELECT 'media1' Type1,
[310],
[520-530],
[850] into temp5
FROM ( SELECT [focomp],
cast(FOBUFMED1QT as int) FOBUFMED1QT
FROM BOFASY
) p PIVOT
( SUM(FOBUFMED1QT)
FOR [focomp] IN ([310], [520-530],[850] )
) AS pvt
insert into temp5
SELECT 'media2' Type1,
[310],
[520-530],
[850]
FROM ( SELECT [focomp],
cast(FOBUFMED2QT as int) FOBUFMED2QT
FROM BOFASY
) p PIVOT
( SUM(FOBUFMED2QT)
FOR [focomp] IN ([310], [520-530],[850] )
) AS pvt
select * from temp5
No comments:
Post a Comment