摘要:
下文讲述MySQL常见数学函数的说明,如下所示:
mysql > select round(2.34);
+-------------+
| round(2.34) |
+-------------+
| 2 |
+-------------+
1 row in set (0.00 sec)
mysql > select round(2.34,1);
+---------------+
| round(2.34,1) |
+---------------+
| 2.3 |
+---------------+
1 row in set (0.00 sec)
mysql > select round(2.36,1);
+---------------+
| round(2.36,1) |
+---------------+
| 2.4 |
+---------------+
1 row in set (0.00 sec)
mysql> select ceil(3);
+---------+
| ceil(3) |
+---------+
| 3 |
+---------+
1 row in set (0.00 sec)
mysql> select ceil(3.12);
+------------+
| ceil(3.12) |
+------------+
| 4 |
+------------+
1 row in set (0.00 sec)
mysql> select ceil(3.62);
+------------+
| ceil(3.62) |
+------------+
| 4 |
+------------+
1 row in set (0.00 sec)
mysql > select ceil(3.02);
+------------+
| ceil(3.02) |
+------------+
| 4 |
+------------+
1 row in set (0.00 sec)
mysql > select floor(0.98);
+-------------+
| floor(0.98) |
+-------------+
| 0 |
+-------------+
1 row in set (0.00 sec)
mysql > select floor(1.98);
+-------------+
| floor(1.98) |
+-------------+
| 1 |
+-------------+
1 row in set (0.00 sec)
mysql > select floor(1.28);
+-------------+
| floor(1.28) |
+-------------+
| 1 |
+-------------+
1 row in set (0.00 sec)
mysql > select truncate(1.66,1);
+------------------+
| truncate(1.66,1) |
+------------------+
| 1.6 |
+------------------+
1 row in set (0.00 sec)
mysql > select truncate(1.69,1);
+------------------+
| truncate(1.69,1) |
+------------------+
| 1.6 |
+------------------+
1 row in set (0.00 sec)
mysql > select truncate(1.60,1);
+------------------+
| truncate(1.60,1) |
+------------------+
| 1.6 |
+------------------+
1 row in set (0.00 sec)
mysql > select mod(10,3);
+-----------+
| mod(10,3) |
+-----------+
| 1 |
+-----------+
1 row in set (0.00 sec)
mysql > select mod(7,2);
+----------+
| mod(7,2) |
+----------+
| 1 |
+----------+
1 row in set (0.00 sec)