Round to the closest .25

select Sample,
  Round( ( Sample + Sign( Sample ) * 0.125 ) * 4, 0, 1 ) / 4.0 as Rounded
  from ( values ( 0.0 ), ( 0.1 ), ( 1.125 ), ( 0.25 ), ( 10.5 ),
    ( -0.75 ), ( -0.875 ), ( -1.12 ), ( -1.125 ) )
    as Samples( Sample )

Note that ROUND can be used to truncate the fractional part of a value regardless of the sign. FLOOR will always return a value equal to or less than the original value, which can be problematic when the value is negative.


use ROUND(value/25, 2) * 25 like this:

Example1:

DECLARE @value DECIMAL(18, 2)
SET @value = 1.126
SELECT CAST(ROUND(@value/25, 2) * 25 as numeric(18,2)) AS rounded_val

Output:

1.25

Example2:

DECLARE @value DECIMAL(18, 2)
SET @value = 1.124
SELECT CAST(ROUND(@value/25, 2) * 25 as numeric(18,2)) AS rounded_val

Output:

1.00

Tags:

Tsql