Analysis of the Round (), Floor (), Ceiling () functions in SQL, and roundceiling

Source: Internet
Author: User

Analysis of the Round (), Floor (), Ceiling () functions in SQL, and roundceiling

A scalar value function is used in a function module of the project, and the function has the usage of the ceiling () function. I found some information and made a simple record of these functions in SQL, easy to learn. If you have any shortcomings, please click here.

1. The round () function follows the rounding principle and is used to round a value field to a specified decimal place.

2. The floor (value) function returns the smallest integer less than or equal to the specified value.

3. The ceiling (value) function returns the smallest integer greater than or equal to the specified value.

For example, for 12.9, floor (12.9) returns 12; ceiling (12.9) returns 13; round (12.9, 0) returns 13

Standard usage of the round () function:

Select round (column_name, decimals) from table_name

SQL instance: There is a Products table

Now, round the price to the nearest integer.

Select ProductName, round (UnitPrice, 0) as UnitPrice from Products

The result is as follows:

This is a record made by myself for future study.

 

Related Article

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.