SQL Server
==================================================== "Round rounding Intercept" select round (54.56,0) ==================================================== "Rounding Down" select floor (54.56) ============================================ ======== "rounding up intercept" select ceiling (13.15)
--The use of the whole function of MSSQL--Dividing two integers truncates fractional partsSelect3/4,4/3,5/3--Result 0,1,1--Returns the smallest integer greater than or equal to the given number expressionSELECTCEILING (123.55),CEILING (123.45),CEILING (-123.45),CEILING (0.0)--Result 124,124,-123,0--Www.2cto.com--Round Round (A, B)--result A is accurate to the decimal right, or the left-b bitSelectRound54.36,-2),Round54.36,-1),Round54.36,0),Round54.36,1),Round54.36,2)--Result 100.00,50.00,54.00,54.40,54.36---Rounding and converting to integersSelectCastRound56.361,0)Asint),CastRound56.561,0)AsInt)--Result 56,57--Use for example---Divide two integers to discard fractional parts (all forward bits)Declare@dividendDecimal00n2),@divisorDecimal00n2)Set@dividend=3Set@divisor=4SelectCEILING (@dividend/@divisor)--Results 1Set@dividend=4Set@divisor=3SelectCEILING (@dividend/@divisor)--Results 2Set@dividend=5Set@divisor=3SelectCEILING (@dividend/@divisor)--Results 2---two integers rounded to integersSet@dividend=3Set@divisor=4SelectCastRound@dividend/@divisor,0)AsInt)--Results 1Set@dividend=4Set@divisor=3SelectCastRound@dividend/@divisor,0)AsInt)--Results 1Set@dividend=5Set@divisor=3SelectCastRound@dividend/@divisor,0)AsInt)--Results 2==================================================== "Round rounding Intercept" select round (54.56,0) ==================================================== "Rounding Down" select floor (54.56) ============================================ ======== "rounding up intercept" select ceiling (13.15)
An instance of SQL up, down rounding, rounding round rounding! Round, RoundDown, roundup