Start Free Trial
Come for the solution, stay for everything else.
Start Free Trial
Round decimal to nearest .25
Is there a way to round a decimal to nearest .25%?
Select 3.6333 would return 3.75 and
3.6222 would return 3.50
Microsoft SQL Server 2005
Microsoft SQL Server
8/22/2022 - Mon
multiply by 4, round to nearest whole number, divide by 4.
ASKER CERTIFIED SOLUTION
Log in or sign up to see answer
Become an EE member today
7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Or, one other alternative:
floor((value + 0.12) / 0.25) * 0.25
select value, floor((value + 0.12) / 0.25) * 0.25 as rounded_value
select 3.6333 as value union all --would return 3.75
select 3.6222 --would return 3.50
) as data
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
Scott - I think you may be slightly off. 3.63 would be the point where your number begins to round up to 3.75, but it should start rounding up at 3.625.
The alternative would be floor((value + 0.125) / 0.25) * 0.25
I am using the floor function in another program to test, but I do think it should be 0.125, not 0.12.
OK, 0.125 makes sense.
I was trying to find a method where you could round at any value, such as .15, rather than using something like "* 4", where it requires having an even multiple and re-calculating the multiplier.
Cleanest answer for me
to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Plans and Pricing
Certified Expert Program
© 1996-2022 Experts Exchange, LLC. All rights reserved. Covered by US Patent