位置:首頁 > 數據庫 > 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)