MIn & MAX features

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
appcon
Participant
Posts: 23
Joined: Wed Jul 07, 2004 8:11 am

MIn & MAX features

Post by appcon »

Hi,

I need to output the min and max values of a column . Is there any function or feature for this.

Could anyone suggest a solution for this.

Thanks.
Sri.
denzilsyb
Participant
Posts: 186
Joined: Mon Sep 22, 2003 7:38 am
Location: South Africa
Contact:

Post by denzilsyb »

Hi Sri

Have you looked at the Aggregator stage? That could be one solution, but my experience of this stage is that it takes a while to do the necessary computations (especially with a few hundred thousand rows).

Another solution would be to use an ODBC stage and just do a select from the tables - let the db do the work.
dnzl
"what the thinker thinks, the prover proves" - Robert Anton Wilson
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use a stage variable for each, for example called MinCol and MaxCol.

MinCol is derived as

Code: Select all

If InLink.TheCol < MinCol Then InLink.TheCol Else MinCol
MaxCol is derived as

Code: Select all

If InLink.TheCol > MaxCol Then InLink.TheCol Else MaxCol
In the final row you will have the desired information.

This is just one solution of many.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Ray

What is the trick to know this is the final row?
Mamu Kim
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Whatever you like, depending on design.

The dummy line on the end of the input file.
The last line of the output file (tail -1 outputfile).
The Aggregator stage featuring a "Last" aggregate function.
(Over)Write to hashed file with constant key value.
Replace row in table.
@OUTROWNUM = previously-known row count.
and so on
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Found this in the Release Notes for 7.5:
End-of-Data Row in IMS Stages
-----------------------------
The IMS stage now includes the option to add an end-of-data indicator after the last row is processed on the output link.
Why don't they spread a little more of that around, eh? :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply