sql 中取整,四舍五入取整,向下取整,向上取整。

时间:2023-12-21 13:11:56
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都取到整数,不含小数。