I need to do this table transformation, but its little hard for me.
I have original table wich looks like this
enter image description here
and i need to transform the table into this
enter image description here
How can i do that ?
Here i prepared example database http://sqlfiddle.com/#!3/0f324
Thank you for helping.
asked Nov 16, 2014 at 9:31
1 Answer 1
select * from
(
select SubBrand,Month,Saless,Variable
from
(select * from DataTable
)as p
unpivot (Saless for Month in(January,February)) as u
) as p
pivot
(
min(Saless) for Variable in ([Sales],[Promotion])
)as PP
order by SubBrand,Month
answered Nov 16, 2014 at 11:49
lang-sql