Wrox Programmer Forums
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 17th, 2009, 04:37 AM
Authorized User
 
Join Date: Nov 2008
Posts: 21
Thanks: 3
Thanked 0 Times in 0 Posts
Send a message via MSN to MonkeyMan666
Default Multiple column Pivot

Hi everyone,

I am having a bit of difficulty trying to figure out the best way to do this transformation.

I have a table e.g.

Column1 Column2 Column3
--------------------------------
Customer1 Type1 1
Customer1 Type2 2
Customer2 Type1 3
Customer2 Type2 4

But I want to create a pivot view something similar to

Type Customer1 Customer2
--------------------------------
Type1 1 3
Type2 2 4

Is this possiblein one query? I am able to do individual rows using pivot queries but I am trying to make this more efficient as my views seems to be getting a bit messy with multiple queries.

Any help would be much appreciated ^_^.

Thanks

MonkeyMan666
 
Old August 17th, 2009, 10:26 AM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

Yes... it's not only possible but it's easy to do, as well. I'm at work and don't have the time (right now) to write some code for your specific example, but here's a pretty good article on it.

http://www.sqlservercentral.com/articles/T-SQL/63681/
__________________
--Jeff Moden
The Following User Says Thank You to Jeff Moden For This Useful Post:
MonkeyMan666 (August 20th, 2009)
 
Old August 20th, 2009, 07:05 AM
Authorized User
 
Join Date: Nov 2008
Posts: 21
Thanks: 3
Thanked 0 Times in 0 Posts
Send a message via MSN to MonkeyMan666
Default

Thanks Jeff, useful article :-)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple IIF statements in one column? bwalk037 Access VBA 4 April 10th, 2009 07:59 AM
Multiple Pivot Table Build Issue baycolor Excel VBA 0 March 21st, 2008 10:15 AM
DTS - Multiple Column Lookup Problem asimahmed SQL Server DTS 2 April 4th, 2006 01:58 PM
Selected column name in Pivot Table harmony82 Access 0 July 25th, 2005 04:25 PM
Multiple column for combobox in C# twaghorn C# 1 July 14th, 2003 04:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.