Page 1 of 1

Combinine two or more identical rows

Posted: Fri Feb 15, 2008 1:43 am
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

Posted: Fri Feb 15, 2008 2:20 am
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.

Posted: Fri Feb 15, 2008 2:35 am
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

Posted: Fri Feb 15, 2008 2:41 am
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?

Posted: Fri Feb 15, 2008 2:50 am
by praburaj
No. My condition is if date and ro_code are same i want to combine multiple rows into single row

Thanks

Posted: Fri Feb 15, 2008 3:43 am
by JoshGeorge
Use stage variables in transformer and adopt remove duplicate strategy to merge fields. Explore Sort stage with keychange as well.

Posted: Fri Feb 15, 2008 5:20 am
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