Combinine two or more identical rows

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
praburaj
Premium Member
Premium Member
Posts: 133
Joined: Thu Jun 30, 2005 1:26 am
Location: philippines

Combinine two or more identical rows

Post by praburaj »

Just i want to know how to combine identical rows(date)in a column

sample data

date ro_code desc mv sv uv C
01/10/2006 12 REGION 0 1 0 0
02/10/2006 12 REGION 0 1 0 0
03/10/2006 12 REGION 0 1 1 0
01/10/2006 12 REGION 0 0 1 0
02/10/2006 12 REGION 0 0 1 0


CAN ANYONE PLZ HELP ME HOW TO COMBINE IDENTICAL ROWS LIKE ROW1 AND ROW 3 HAVING SAME DATE, ROCODE AND DESC. AND ROW2 AND
ROW 4
AS WELL..

THANK U
prabakaran.v
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The rows aren't identical, some of the columns are. You haven't described what the combined row is to look like or what the combination rules are.
This type of thing is commonly done in DataStage.
praburaj
Premium Member
Premium Member
Posts: 133
Joined: Thu Jun 30, 2005 1:26 am
Location: philippines

Post by praburaj »

Hi Arndw,
I want to combine output like this


01/10/2006 12 REGION 0 1 1 0
02/10/2006 12 REGION 0 1 1 0

can u help me how to combine?

Thanks

prabakaran
prabakaran.v
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

So your rule is "if the date and the ro_code are the same, then do a logical "OR" on the column values"? Is that correct?
praburaj
Premium Member
Premium Member
Posts: 133
Joined: Thu Jun 30, 2005 1:26 am
Location: philippines

Post by praburaj »

No. My condition is if date and ro_code are same i want to combine multiple rows into single row

Thanks
prabakaran.v
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

Use stage variables in transformer and adopt remove duplicate strategy to merge fields. Explore Sort stage with keychange as well.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
MOHAMMAD.ISSAQ
Participant
Posts: 78
Joined: Fri Mar 02, 2007 4:54 am
Location: CHENNAI

Post by MOHAMMAD.ISSAQ »

As Arndw said you can do it by using logical "or" operator.
Take your ouput as hash file and use the same hash file for reference in the same job.
Then take 4 stage variables for Date and Row_cd.
E.g:
Pre_Date->HshFile.Date,Curr_Date->SeqFile.Date lly for row_cd.

Then take one temp stage variable and write the logic in it as:

"If (Pre_Date <> Curr_Date ) Or (Pre_RowCd <> Curr_RowCd) Then
"N"
Else
(Seq.mv Or DSLink6.mv):(Seq.sv Or DSLink6.sv):(Seq.uv Or Hsh.uv):(Seq.C Or Hsh.C)"


Then in your hash file write as
OuputHshFile.mv->"If Varmv <> "N" Then Varmv[1,1] Else DSLink4.mv"

Similarly for others
Post Reply