oak29
asked on
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!
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.
Hi,
you can use following logic,
just ignore following when implementing
Declare @val as int
Set @val = 1000000
...
Print(@val)
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)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That works really well. Thanks!
Open in new window