# An instance of SQL up, down rounding, rounding round rounding! Round, RoundDown, roundup

Source: Internet
Author: User

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

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.