Skip to main content

ABS

Functions › Number

Returns a number without its sign.

Syntax​

ABS( <number> )

Arguments​

ArgumentDescription
<number>A number, or text that reads as a number.

Returns​

An integer for an integer argument; otherwise a float. NULL when <number> is NULL. Text that does not read as a number fails the query.

Usage notes​

  • On a number column the engine runs it in the data store; on text it runs after the rows are read.

Examples​

How far each invoice is from its expected total:

SELECT i.invoice_no, i.amount, i.expected,
ABS(i.amount - i.expected) AS difference
FROM data.invoices i
ORDER BY difference DESC
invoice_noamountexpecteddifference
INV-104820.5950129.5
INV-1011200118020
INV-1023003000

See also​

SIGN · ROUND · Operators