?
Solved

Pivot/Unpivot

Posted on 2010-11-25
2
Medium Priority
?
517 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 1000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
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…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

801 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