Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Rounding function and decimal in SQL

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Take the entire function:

1. Trunc (value,precision) intercepts a number by precision without rounding.

Returns the x value of the decimal place truncated to y: trunc (x, [y]):

Select trunc 23.33-23

2. Round (value,precision) enter the value [rounded off] according to the given precision (precision).

Returns the x value rounded to the right of the decimal point: round (x, [y]):

Select round 23.33-23

3. Ceiling (value) produces the smallest integer greater than or equal to the specified value (value) [rounded up].

Returns the largest integer greater than or equal to x:

Select ceiling (23.33)-24

4. Floor (value), contrary to ceiling (), produces the smallest integer that is less than or equal to the specified value (value).

Returns the largest integer equal to or less than x:

Select floor 23.33-23

5. Sign (value) is opposite to the absolute value function ABS (). ABS () gives the quantity of the value instead of its symbol, while sign (value) gives the symbol of the value instead of the quantity.

Returns the symbol of x:

Select sign (- 23.33)-1 Summary:

[rounding]: round ()

[round down]: FLOOR (), cast (x as int). The number of days of the date cannot be used with cast, and floor (cast (date as float)) is required.

[round up]: CEILING ()

[decimal]: x-floor (x)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report