SQL round (), trunc (), floor (), Ceil () function

Source: Internet
Author: User
1 trunc (value, precision) truncates a number by precision without rounding. 2 round (value, precision) inputs a value based on the given precision. 3 Ceil (value) generates the smallest integer greater than or equal to the specified value. 4. Opposite to Ceil (), floor (value) produces the smallest integer smaller than or equal to the specified value. 5 sign (value) is opposite to the absolute value function ABS. ABS () gives the number of values rather than its symbol. Sign (value) gives the symbol of the value rather than the number. Example: trunc (11,2) = 11 trunc (-22,2) =-22 round (11,2) = 11 round (-22,2) =-22 trunc (33.33, 2) = 33.33 trunc (-44.44, 2) =-44.44 round (33.33, 2) = 33.33 round (-44.44, 2) =-44.44 trunc (55.5, 2) = 55.5 trunc (-55.5, 2) =-55.5

Round (55.5, 2) = 55.5 round (-55.5, 2) =-55.5 trunc (66.666, 2) = 66.66 trunc (-77.777.5, 2) =-77.77 round (66.666, 2) = 66.67 round (-77.777, 2) =-77.78 so these two functions work only when the number of decimal places exceeds the precision. Round (55.5) = 56 round (-55.5) =-56 trunc (55.5) = 55 trunc (-55.5) =-55 Ceil (55.5) = 56 Ceil (-55.5) =-55 floor (55.5) = 55 floor (-55.5) =-56 sign (146) = 1 ABS (146) = 146 sign (-30) =-1 ABS (-30) = 30 sign (0) = 0

Contact Us

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.