difference between two 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
adams06
Participant
Posts: 92
Joined: Sun Mar 12, 2006 3:00 pm

difference between two rows

Post by adams06 »

How to get difference between two rows for a column field?

ex:

Code: Select all

rowInt  Value
99       0
98       1
97      10
96       0
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That's an example of what - your input data? If so, what would your desired output data look like?
-craig

"You can never have too many knives" -- Logan Nine Fingers
adams06
Participant
Posts: 92
Joined: Sun Mar 12, 2006 3:00 pm

Post by adams06 »

thats the input

rowInt Value
97 9
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sorry but we'll need more detail than that to provide a legitimate answer. What are your rules for computing this "difference"?
-craig

"You can never have too many knives" -- Logan Nine Fingers
adams06
Participant
Posts: 92
Joined: Sun Mar 12, 2006 3:00 pm

Post by adams06 »

I am in the process of reading sqlldr log file

skipped 0
read 10
rejected 1
discarded 0

so i need to compute the records loaded. Thats the background :D
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Good to know, should have put that in your original post. So... you want:

read - rejected - discarded?

For that I would just use the aggregator. For the last two rows, multiply the number by -1 before sending it to aggregation and then sum() them. What about the skipped value if it is non-zero? You may need to not send it to the aggregator at all, if that's the case just use a constraint.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Otherwise use stage variables in a Transformer stage to "remember" the value from the previous row, a technique that has been explained more than once on DSXchange.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
adams06
Participant
Posts: 92
Joined: Sun Mar 12, 2006 3:00 pm

Post by adams06 »

Chulett your suggestion works for me thanks for the help.
Post Reply