[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Pivot/Unpivot

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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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 …
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

656 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