Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

SQLite abs() function

Description

SQLite abs() function returns the absolute value of a number.

  • The abs(X) function returns the absolute value of the numeric argument X. Abs(X) returns NULL if X is NULL.
  • abs(X) return 0.0 if X is a string or blob that cannot be converted to a numeric value.
  • If X is the integer -9223372036854775808 then abs(X) throws an integer overflow error since there is no equivalent positive 64-bit two complement value.

Syntax:

abs(X)

Argument

Name Description
X A number whose absolute value is to be retrieved.

Example: SQLite abs() function

The following SQLite statement will return the absolute value of a positive number specified in the argument.

sqlite> SELECT abs(5);

Here is the result.

Sample Output:

abs(5)
----------
5

Example: SQLite abs() function using negative value

The following SQLite statement will return the absolute value of a negative number defined in the argument.

sqlite> SELECT abs(-5);

Here is the result.

Sample Output:

abs(-5)
----------
5

Previous: Sum()
Next: changes()