MAx of two negative decimal

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
consulting
Participant
Posts: 50
Joined: Fri Dec 21, 2007 3:24 am

MAx of two negative decimal

Post by consulting »

My requirement is I want to find the max of two negative decimals
for eg;

max(-89.62,-88.02) I want the output as -89.62

but I am getting 0 The output feils data type is decimal(10,2)

Can you please help me
balaji
vjonnala1516
Participant
Posts: 18
Joined: Fri Jan 04, 2008 5:28 am
Location: Bangalore

Post by vjonnala1516 »

It has to work, check the data just before the comparision.
VJ
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

You have stated your requirement incorrectly based on your example. Perhaps a correct requirements statement will guide you to a proper solution.

What seems to be your requirement:
When comparing two negative numbers, choose the value having the largest absolute value.

Mike
throbinson
Charter Member
Charter Member
Posts: 299
Joined: Wed Nov 13, 2002 5:38 pm
Location: USA

Post by throbinson »

I've never used this function and if I had a dime for all the times things "have to work" but didn't I wouldn't be sitting here writing this. I have, however, used the help button in Datastage.
To wit;
Max

Code: Select all

 Returns the greater of the two argument values
 number 1 (int32) number 1 (int32)
 result (int32)
 
I'm thinking decimals are not allowed for this function.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: MAx of two negative decimal

Post by chulett »

consulting wrote:My requirement is I want to find the max of two negative decimals
for eg;

max(-89.62,-88.02) I want the output as -89.62
As noted, the 'max' of those two values is -88.02 as -89.62 is less than -88.02.
-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 »

Remember back at school, when they taught you about the number line?

As Craig observed, -89.62 is less than -88.02. Therefore the Max() function is yielding the correct result.

You need to consider what you really want. It sounds like you want the number with the larger absolute value. (If you can be certain that both numbers are negative, this is - of course - given by the Min() function. Otherwise, something like Max(Abs(FirstNumber),Abs(SecondNumber)) is what you need.)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
throbinson
Charter Member
Charter Member
Posts: 299
Joined: Wed Nov 13, 2002 5:38 pm
Location: USA

Post by throbinson »

He wants -89.62 but is getting zippage. Will max() work with a decimal?
Post Reply