Page 1 of 1

Finding Max and Min on varchar column

Posted: Mon Dec 31, 2012 12:25 am
by sriram_bcl
Can any one suggest how to find Maximum and Minimum on varchar column in Datastage 8.1

Posted: Mon Dec 31, 2012 1:23 am
by ray.wurlod
Welcome aboard. Use an Aggregator stage.

Re: Finding Max and Min on varchar column

Posted: Mon Dec 31, 2012 1:32 am
by sriram_bcl
Thanks for the reply. I tried all the possibilities with Agg. We have incoming data contains like 'abcdefg' etc. we are facing issue in finding min and max on string. In server job using aggregator we are able to do. in PX i am not able to do it. Plz suggest

Posted: Mon Dec 31, 2012 2:04 am
by jerome_rajan
Please post the expected and the actual outputs.

Re: Finding Max and Min on varchar column

Posted: Mon Dec 31, 2012 3:11 am
by sriram_bcl
My iniput column contains
112A
112B
112C

My output should be Max(Column) i.e 112C

Posted: Mon Dec 31, 2012 3:23 am
by ArndW
I just tried it and it would seem that the MAX() function of the aggregator stage is limited to numeric data in Parallel jobs.

Along similar lines to what Ray mentioned, use one stream for a sort and a remove duplicates (first or last, depending upon whether you want a min or a max value) to get the highest or lowest value of that field.

Posted: Mon Dec 31, 2012 3:45 am
by sriram_bcl
This problem persist in existing project. Combination of Sort and Remove duplicate did not work. We tried long time back but did not work.

Posted: Mon Dec 31, 2012 6:17 am
by ArndW
That's quite odd, I did a test job earlier to see about the aggregator and had a functioning max() working using a sort and remove duplicates within 5 minutes. Perhaps you might want to revist your approach, and if you wish assistance here you might wish to post what you did and what the problem was.

Posted: Mon Dec 31, 2012 7:00 am
by venkateshrupineni
u can do using only sort stage and sort the data in desc select first record using transformer stage (read transformer stage in sequential mode) and write constraint is @inrownum=1 if you need only one record.

Posted: Mon Dec 31, 2012 4:50 pm
by ray.wurlod
There is a Preserve Type property (or some such name) in the Aggregator stage that allows it to work with string data, among other things.