SQL/MySQL/Math/Floor Ceiling

Материал из SQL эксперт
Перейти к: навигация, поиск

Use CEILING in MySQL

/*
mysql> select CEILING(-1.4);
+---------------+
| CEILING(-1.4) |
+---------------+
|            -1 |
+---------------+
1 row in set (0.01 sec)
mysql> select CEIL(0.5);
+-----------+
| CEIL(0.5) |
+-----------+
|         1 |
+-----------+
1 row in set (0.01 sec)

*/  
select CEILING(-1.4);
select CEIL(0.5);



Use FLOOR in MySQL

/*
mysql> select FLOOR(12.345);
+---------------+
| FLOOR(12.345) |
+---------------+
|            12 |
+---------------+
1 row in set (0.00 sec)
mysql> select FLOOR(-12.3456);
+-----------------+
| FLOOR(-12.3456) |
+-----------------+
|             -13 |
+-----------------+
1 row in set (0.00 sec)

*/  
select FLOOR(12.345);
select FLOOR(-12.3456);