Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Round to nearest x

Status
Not open for further replies.

haste

Programmer
Feb 27, 2005
96
GH
Is there any function that can be used to round to a number let say 100. I'm calculating a tax deduction, ded1, that is derived from a maximum deduction value, the percentage payable and a rounding accuracy (round_to_amt). For example:

Given
Maximum deduction = 400
percentage payable = 50%
and
round_to_amt = 100

Then
tax dedution = 200

I'm using the ROUND function as below

Code:
ROUND( (400 * 50 * .01), (100/10)),

but that only gives accuracy to 10 decimal places.
 
I worked round the problem like this:

select (400 * 50 * .01) + MOD(((400 * 50 * .01)), 100)
from dual;

Cleaned up its:

Code:
select (400 * .5 )  + MOD( (400 * .5), 100)
from dual;

The problem it has is the round to moment exceeds the max deduction it returns (400 * .5) as the mod function returns zero.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top