0

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.

1 Answer 1

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
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.