troubleshooting Question

SQL Select to change record orientation from horizontal to vertical

Avatar of tmajor99
tmajor99 asked on
SQL
4 Comments1 Solution134 ViewsLast Modified:
I need a SQL select that can change the orientation of my record.  My input file contains one row per unique ID with separate columns for each reference ID and Type.  I need to format each row by breaking out each column reference type and ID into a new row.  



Input Table:

ID               Reference1 ID      Reference1 Type      Reference 2  ID             Reference2 Type
--------      -------------       -------------               -----------------            -----------------
10000       82                               GPH                             63                              LineBuy
10001       55                               GPH                             43                              LineBuy                                                                
10002                                                                                32                              LineBuy

Output Table:

ID              Reference ID        Reference Type
---------    -------------        ----------------
10000        82                        GPH
10000        63                        LineBuy
10001        55                        GPH
10001        43                        LineBuy
10002        32                        LineBuy
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 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 4 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