Page 1 of 1

MIn & MAX features

Posted: Thu Jul 15, 2004 8:41 am
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.

Posted: Thu Jul 15, 2004 9:03 am
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.

Posted: Fri Jul 16, 2004 4:01 am
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.

Posted: Fri Jul 16, 2004 5:40 am
by kduke
Ray

What is the trick to know this is the final row?

Posted: Fri Jul 16, 2004 3:55 pm
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

Posted: Fri Jul 16, 2004 3:59 pm
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: