several lines towards a line

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
auvray.muriel
Participant
Posts: 43
Joined: Wed Feb 19, 2003 7:17 am
Location: France - Paris
Contact:

several lines towards a line

Post by auvray.muriel »

Hello,

I have several lines which I would like to put on only one line.

I have

Key_1|Key_2
1 A
1 B
1 C
2 A
2 C
3 B

I want

1 A B C
2 A C
3 B

I do not know how much it can exist events.
How then to make?

Thanks

Muriel Auvray
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Use stage variables (search the forum) to pivot your many rows into one. You'll have to add an extra row of data into your primary input stream to signal the end of the data to output the last row. Your data must be sorted and grouped.

Another method is to write to a hash file, referencing the row back and concatenating. This method works for unsorted data, but is slower than sorted data (which requires time for sorting anyway).

A third method is to use a custom script to manually roll up the data.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Post Reply