本章我们会学习my SQL最实用的基本的内置函数,用来应对numeric,daytime,and string values
比如round,truncate,ceiling,floor,abs,rand
1,四舍五入数值round
保留一位小数,Round to one decimal place
2,truncate函数,比如不四舍五入,保留小数点后n位小数,其余截断
select truncate(5.7385,2) 输出5.73
3,ceiling函数(上限函数)
select ceiling(5.7385) 输出6
select ceiling(5.1385) 输出也是6
4,floor函数
select floor(5.1385) 输出5
select floor(5.7385) 输出也是5
5,ABS函数,计算绝对值
select abs(5.7385) 输出5.7385
select abs(-5.7385) 输出5.7385
6,round函数,Generate random floating point numbers in the 0-1 interval
select round(-5.7385) 输出-6
select round(5.7385) 输出6
还有其他的函数,这里暂时不举例