SQL help needed please!

Associate
Joined
17 Nov 2003
Posts
1,945
Location
Gateshead
Morning all

I have this table in SQL (2005), generated by a third party and cannot be changed...

Table1.png


T1, T2, T3 and T4 are monthly targets. In reality this table is around 250 rows.

A different third party needs to access this data in a different format; a new table is fine. I needs it to look like...

Table2.png


I did something similar many, many moons ago using a PIVOT in SQL but cannot for the life of me apply what I learned way back when to this.

I'm not saying a PIVOT is the best way to go about this. Any ideas or suggestions would be awesome.

Cheers!
 
I would do a pivot to create the first 3 columns of your desired output ("Name","Type","Target") first.

Cheers touch. I was over thinking a little but your idea helped me out. UNPIVOT did the trick with the single column duplicated. It's a very small table so time/processing impact isn't a factor.

I don't understand how T1, T2, T3 and T4 can be monthly targets, but then they want the months as well, it's just duplicating data...

Vendor A gives us data in one format, Vendor B wants it in a different format. I agree there is a lot of duplication but that's not my call, I just have to deal with it :)
 
Back
Top Bottom