mysql> SELECT CEIL(3.01); # 进1取整
+------------+
| CEIL(3.01) |
+------------+
| 4 |
+------------+
1 row in set (0.00 sec)
mysql> SELECT FLOOR(3.99); # 舍1取整
+-------------+
| FLOOR(3.99) |
+-------------+
| 3 |
+-------------+
1 row in set (0.00 sec)
mysql> SELECT 3 / 4; #真正的除法
+--------+
| 3 / 4 |
+--------+
| 0.7500 |
+--------+
1 row in set (0.00 sec)
mysql>
mysql> SELECT 3 DIV 4; #整数除法
+---------+
| 3 DIV 4 |
+---------+
| 0 |
+---------+
1 row in set (0.00 sec)
mysql> SELECT 5 % 3; #取余数
+-------+
| 5 % 3 |
+-------+
| 2 |
+-------+
1 row in set (0.00 sec)
mysql> SELECT 5 MOD 3; #取余数
+---------+
| 5 MOD 3 |
+---------+
| 2 |
+---------+
1 row in set (0.01 sec)
mysql> SELECT POWER(3,3); #幂运算
+------------+
| POWER(3,3) |
+------------+
| 27 |
+------------+
1 row in set (0.05 sec)
mysql> SELECT ROUND(3.654, 2); #四舍五入
+-----------------+
| ROUND(3.654, 2) |
+-----------------+
| 3.65 |
+-----------------+
1 row in set (0.00 sec)
mysql> SELECT ROUND(3.654, 1);
+-----------------+
| ROUND(3.654, 1) |
+-----------------+
| 3.7 |
+-----------------+
1 row in set (0.00 sec)
mysql> SELECT TRUNCATE(125.89, 2); # 数字截取
+---------------------+
| TRUNCATE(125.89, 2) |
+---------------------+
| 125.89 |
+---------------------+
1 row in set (0.00 sec)
mysql> SELECT TRUNCATE(125.89, 1);
+---------------------+
| TRUNCATE(125.89, 1) |
+---------------------+
| 125.8 |
+---------------------+
1 row in set (0.00 sec)
mysql> SELECT TRUNCATE(125.89, 0);
+---------------------+
| TRUNCATE(125.89, 0) |
+---------------------+
| 125 |
+---------------------+
1 row in set (0.00 sec)
mysql> SELECT TRUNCATE(125.89, -1); #很少用到
+----------------------+
| TRUNCATE(125.89, -1) |
+----------------------+
| 120 |
+----------------------+