Avatar of mikegrad7
mikegrad7Flag for United States of America

asked on 

SQL Server Transpose , partially at least

Hi, i am trying to create a SQL Sp that will output some data, but it needs to do a partial transpose.

the current data is in rows, and looks like this. Lets call this Table CURRDATA
ID 1             ID2           TYPE        RATE   END_DATE
ABC123      786efr      XXX         5.5       12/31/2019
XXYYZZ       AABBCC   YYY         6.9        6/30/2020

etc... they key for the table is the combination of ID1 and ID 2

I need to re-arrange this output for import to another system, and it needs to be somewhat transposed. The output should look like this, with a line for each value outside the key.
 
ID1               ID2                Property                    Value
ABC123      786efr            TYPE                           XXX
ABC123      786efr            RATE                           5.5
ABC123      786efr            END_DATE                 12/31/2019
XXYYZZ       AABBCC         TYPE                           YYY
XXYYZZ       AABBCC         RATE                           6.9
XXYYZZ       AABBCC          END_DATE                6/30/2020

Can someone help me write this SQL to get the desired output?
Microsoft SQL ServerProgrammingSQL

Avatar of undefined
Last Comment
mikegrad7
SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
ASKER CERTIFIED SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
mikegrad7, do you still need help with this question?
Avatar of mikegrad7
mikegrad7
Flag of United States of America image

ASKER

thanks to everyone for you help, i was able to get this working as i needed.
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo