Rounding to 4 decimal places

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
cdp
Premium Member
Premium Member
Posts: 113
Joined: Tue Dec 15, 2009 9:28 pm
Location: New Zealand

Rounding to 4 decimal places

Post by cdp »

I've got a requirement where I need to round a decimal (Length 19, Scale 7) value to the 4th decimal.

In SQL, the example function and result will look like:

select ROUND(26.086464,4) -> result is 26.086500

I've had a look at previous posts and the Developer's Guide, but I can't see how the CEIL, FLOOR, round_inf, DecimalToDecimal(Number,Rounding) function can be of any use as it only caters for decimal length of 10 and a scale of 2.

Any idea how I can round to the 4th decimal place as done by the SQL above?
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Have you tried any of those options to see if they work for you?

Why do you believe that the rounding type caters to only 10,2 decimals? That's a rather limiting definition.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
jneasy
Participant
Posts: 32
Joined: Sun Jan 29, 2012 8:47 pm
Location: Australia

Post by jneasy »

Have you seen the following?

viewtopic.php?p=338081

Make sure you have scale of the column set to your desired value, i.e. 4.


Joseph Neasy.
cdp
Premium Member
Premium Member
Posts: 113
Joined: Tue Dec 15, 2009 9:28 pm
Location: New Zealand

Post by cdp »

Argh, somehow I thought that the examples in Developer Guide, which was using a scale of 2, would only round to the 2nd decimal place no matter what.

Just by making the target field a decimal (19,4) and using the round_inf function it rounds it correctly.

Thanks for your help guys...
Post Reply