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.

asked Nov 16, 2014 at 9:31

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
answered Nov 16, 2014 at 11:49
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.