Round Up or Down to custom number in SQL Server
Views (438)
Recently I faced the scenario where end user wanted, to check the first decimal number of Net Salary, if it’s greater then or equal to 4 (0.4) round up, otherwise, round down it.
I was able to solve it using below piece of code.
Declare @NetAmount numeric(18,5), @PaymentAmount numeric(18,5);
set @PaymentAmount = FLOOR(@NetAmount)+CASE WHEN Round(@NetAmount, 1, 1) % 1 >= 0.4 THEN 1 ELSE 0 END ;
This was originally posted here.
*This post is locked for comments