troubleshooting Question

SQL Pivot Help

Avatar of FamousMortimer
FamousMortimerFlag for United States of America asked on
Microsoft SQL Server 2008Microsoft SQL Server 2005Microsoft SQL Server
8 Comments1 Solution630 ViewsLast Modified:
Hi Experts,

I have a table like this

Item# | Color |   Ink       |Sequence
123A   | blue   |   A234   | 1    
123A   | red    |    B235   |2
123A   | green|    C236   |3
124B   | red    |    A123   |1
124B   | white |    A124   |2

I would like the output to be like this:

Item# | Station1     | Station2    | Station3
123A   | Color: blue |Color: red | Color: green
              Ink: A234   | Ink: B235  |Ink: C236
124B   | Color: red  |Color: white| NULL
           |Ink: A123    |Ink: A124
The sequence can be anywhere from 1 to 10.

In the output table the color and ink are separated by CHAR(10) so there should be one line returned for each unique item #

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros