Solved

Pivot/Unpivot

Posted on 2010-11-25
2
488 Views
Last Modified: 2012-05-10
What I want can be easily done with Pivot/Unpivot (one of those, I can never figure out which does which). I have a table where I have two relevant fields: CompanyNo and ItemNo. There are more, but I'm doing a distinct query. What I would like is to create an output table with each CompanyNo as row headers and ItemNo as column headers, with an X when there is one.

For example:

               Item1    Item2    Item3
Comp1       X                       X
Comp2       X          X
Comp3       X          X           X
Comp4                   X
0
Comment
Question by:Cluskitt
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 34212783
this is a dynamic pivot request...

see this article, for example, how to implement:
http://www.simple-talk.com/community/blogs/andras/archive/2007/09/14/37265.aspx
0
 
LVL 18

Author Closing Comment

by:Cluskitt
ID: 34228931
I'm sorry for not replying sooner. Been a busy week. Also, I'm having a hard time understanding that article, mostly because I have yet to understand pivot/unpivot correctly. However, I do not doubt that your answer is the correct one, so I'm awarding you with the solution and I'll try to study it better later.
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now