sql 中取整,四舍五入取整,向下取整,向上取整。
Posted 上官飞鸿
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 中取整,四舍五入取整,向下取整,向上取整。相关的知识,希望对你有一定的参考价值。
SELECT
round(52.45, 0) AS round4,
round(52.54, 0) AS round5,
round(52.45, 1) AS round41,
round(52.54, 1) AS round51,
floor(52.4) AS floor4,
floor(52.5) AS floor5,
ceiling(52.4) AS ceiling4,
ceiling(52.5) AS ceiling5
round是四舍五入
floor是向下取整
ceiling 是向上取整
round需要一个位数的参数
floor和ceiling都取到整数,不含小数。
以上是关于sql 中取整,四舍五入取整,向下取整,向上取整。的主要内容,如果未能解决你的问题,请参考以下文章