Page 1 of 1

Merging rows based on the key

Posted: Tue Sep 23, 2008 2:13 pm
by kishorenvkb
Hello All,

I have a need to merge the columns based on the key.
There are multiple rows with similar key. The output should have one row for a given key with the values from each row as different columns.
Ex:

1, 1, a, Hello
1, 1, b, Bye
1, 1, c, Now

With first two columns being the key, I wanted the output to be
1, 1, Hello, Bye, Now (a 5 column output)

The data is already pre-partioned and pre-sorted by the key and also just sorted by the third column (column with values a, b, c).

What is the easiest way to accomplish this? For a similar need, I have done a lengthy process below of storing the previous value, comparing that with the new value and making sure that the last records is also written...

Just checking to see if some one has any other creative ideas regarding this.

Thanks

Posted: Tue Sep 23, 2008 4:16 pm
by ray.wurlod
Search DSXchange for "vertical pivot".