Link to home
Start Free TrialLog in
Avatar of ewang1205
ewang1205

asked on

Round a 6 digit number

I like to have a sql to round a 6 digit number like the following.  The length will alway to 6 digit and I like replace the last none 0 digit with 0.  For example:

122000 to become 120000
120000 to become 100000
133400 to become 133000
133900 to become 133000

ASKER CERTIFIED SOLUTION
Avatar of gatorvip
gatorvip
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of schwertner
schwertner
Flag of Antarctica image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@schwertner: that method will not work if the first 0 is in a significant position. For example, use 103900.
Thats right! Thanks for the remark.
But the method can be fixed, because INSTR fuction can also
work from right to left.
The best way to solve the problem is to write a function.
Functions could be called from SQL statements.
Avatar of ewang1205
ewang1205

ASKER

Thanks for the help.