Vertical Pivoting

Database

Vertical Pivoting

The first 5 columns in below table is the primary key and for that primary key there might be 1 or more SLS_ID. The number of rows for each group of 5 keys is variable. I want to group the table by first 5 columns and then have the SLS_ID concetenated.

INPUT TABLE WITH DATA;

CD_P CD_B CD_S ACT MYYYY SLS_IDS
2U2Z 2V001 YA 38 12009 92
2U2Z 2V001 YA 38 12009 93
2U2Z 2V001 YA 38 12009 99
2U2Z 2V001 YA 38 12009 102
2UKK 2V099 MN 40 12009 91
9NCTS 76GV CT 55 12009 99
9NCTS 76GV CT 55 12009 102

DESIRED DATA FORMAT;

CD_P CD_B CD_S ACT MYYYY SLS_IDS
2U2Z 2V001 YA 38 12009 92,93,99,102
2UKK 2V099 MN 40 12009 91
9NCTS 76GV CT 55 12009 99,102

How to acheive this via SQL?
2 REPLIES
Senior Apprentice

Re: Vertical Pivoting

Have a look at that thread:
http://www.teradataforum.com/teradata/20060710_173415.htm

Dieter
rgs
Enthusiast

Re: Vertical Pivoting

Or have a look at this one in this forum.

http://www.teradata.com/teradataforum/Topic8112-5-1.aspx?