davidvilla
Member
Hi all,
I can easily compare two rows of a table and get the fields and values that are different. Can I compare multiple rows the same way?
Example:
field1 field2 field3 field4
one abc 123 bell
one def 123 bell
one abc 456 bell
two def 456 bell
My result should say:
If I compare all the 4 rows
record1: field1=one,field2=abc,field3=123
record2: field1=one,field2=def,field3=123
record3: field1=one,field2=abc,field3=456
record4: field1=two,field2=def,field3=456
If I compare first 3 rows
record1: field2=abc,field3=123
record2: field2=def,field3=123
record3: field2=abc,field3=456
If I compare first 2 rows
record1: field2=abc
record2: field2=def
The number of rows to compare is dynamic. The result should list all the fields and values that are different in atleast one of the compared records.
I did compare any two rows using:
DOi = 1 TO hRec1Buffer:NUM-FIELDS:
iF hRec1Buffer:BUFFER-FIELD(i):BUFFER-VALUE <> hRec2Buffer:BUFFER-FIELD(i):BUFFER-VALUE THEN
ASSIGN
cRec1Diff = cRec1Diff + (iF cRec1Diff = '':U THEN '':U ELSE ',':U ) + hRec1Buffer:BUFFER-FIELD(i):NAME + "=" + QUOTER(hRec1Buffer:BUFFER-FIELD(i):BUFFER-VALUE,'"')
cRec2Diff = cRec2Diff + (iF cRec2Diff = '':U THEN '':U ELSE ',':U ) + hRec2Buffer:BUFFER-FIELD(i):NAME + "=" + QUOTER(hRec2Buffer:BUFFER-FIELD(i):BUFFER-VALUE, '"').
END.
I can easily compare two rows of a table and get the fields and values that are different. Can I compare multiple rows the same way?
Example:
field1 field2 field3 field4
one abc 123 bell
one def 123 bell
one abc 456 bell
two def 456 bell
My result should say:
If I compare all the 4 rows
record1: field1=one,field2=abc,field3=123
record2: field1=one,field2=def,field3=123
record3: field1=one,field2=abc,field3=456
record4: field1=two,field2=def,field3=456
If I compare first 3 rows
record1: field2=abc,field3=123
record2: field2=def,field3=123
record3: field2=abc,field3=456
If I compare first 2 rows
record1: field2=abc
record2: field2=def
The number of rows to compare is dynamic. The result should list all the fields and values that are different in atleast one of the compared records.
I did compare any two rows using:
DOi = 1 TO hRec1Buffer:NUM-FIELDS:
iF hRec1Buffer:BUFFER-FIELD(i):BUFFER-VALUE <> hRec2Buffer:BUFFER-FIELD(i):BUFFER-VALUE THEN
ASSIGN
cRec1Diff = cRec1Diff + (iF cRec1Diff = '':U THEN '':U ELSE ',':U ) + hRec1Buffer:BUFFER-FIELD(i):NAME + "=" + QUOTER(hRec1Buffer:BUFFER-FIELD(i):BUFFER-VALUE,'"')
cRec2Diff = cRec2Diff + (iF cRec2Diff = '':U THEN '':U ELSE ',':U ) + hRec2Buffer:BUFFER-FIELD(i):NAME + "=" + QUOTER(hRec2Buffer:BUFFER-FIELD(i):BUFFER-VALUE, '"').
END.