Sql Rounding

I'm having some trouble coming up with a solution for this.  In one of my procs I get a certain number.  If this number is greater than 125000 I have to round to the nearest 5000.  If it is less that 125000 I have to round to the nearest 2500.  I'm pretty new to Sql Server so any help would be appreciated!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
something like this
``````declare @x as int
set @x = 132502
select case when @x > 12500
then round(@x/5000,0) * 5000
else round(@x/2500,0) * 2500
end
``````
Commented:

You can do:
IF @Number > 125000
BEGIN
SET @Number =  5000
END
IF @Number < 125000
BEGIN
SET @Number =  2500
END

Let me know if your looking for some different.
Consultant Software Engineer - .NET ArchitectCommented:
Hi,
you can use following logic,

just  ignore following when implementing

Declare @val as int
Set @val = 1000000
...
Print(@val)

``````Declare @val as int
Set @val = 1000000
IF @val > 125000
SET @val =  5000
Else IF @val < 125000
SET @val =  2500

Print(@val)
``````
Commented:
Sorry, by using INT it was always a truncation.

``````declare @y as numeric(18,2)
declare @x as numeric(18,2)
set @x = 132502

-- assign it to a variable
set @y=case when @x > 125000
then round(@x/5000,0,0) * 5000
else round(@x/2500,0) * 2500
end

-- use it directly in a query
select case when @x > 125000
then round(@x/5000,0,0) * 5000
else round(@x/2500,0) * 2500
end
``````

Experts Exchange Solution brought to you by