Terminate to the next 0.05 in SQL Server

I have a requirement when I need rates to be rounded to the nearest nickel. For example, for example:

Rate . ,, Rounded value
1.90. ,, 1.90
1.91. ,, 1.95
1.92. ,, 1.95
1.93. ,, 1.95
1.94. ,, 1.95
1.95. ,, 1.95
1, 96. ,, 2.00
1.97. ,, 2.00
1.98. ,, 2.00
1.99. ,, 2.00
2.00. ,, 2.00

ie, if the place is “encrypted” after the decimal place, it must be rounded to the next 0.05 .
I wrote a query that gives me a value for the nearest 0.05 not until the next 0.05.

select Rate, (Round((Rate)/0.25 , 2)*0.25) as RoundRate   from ProposedProductPrice order by created desc
+4
1

ceiling, round up. 20, 20 , 20:

select ceiling(Rate * 20) / 20;
+6

Source: https://habr.com/ru/post/1665207/


All Articles