位置:首页 > 数据库 > SQL在线教程 > SQL ABS()函数

SQL ABS()函数

ABS(X)

ABS()函数返回X的绝对值,请考虑以下的例子:

SQL> SELECT ABS(2);
+---------------------------------------------------------+
| ABS(2)                                                  |
+---------------------------------------------------------+
| 2                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)

SQL> SELECT ABS(-2);
+---------------------------------------------------------+
| ABS(2)                                                  |
+---------------------------------------------------------+
| 2                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)