Solved

Pivot/Unpivot

Posted on 2010-11-25
2
514 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

729 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