ABS

The ABS function returns the absolute value of the specified numeric expression.

ABS Syntax

Use the following syntax when incorporating the ABS function in queries:

ABS(expression)

Where expression evaluates to a numeric value.

ABS Examples

The example queries in this section run against the AnzoGraph sample Tickit data set, which captures sales activity for a fictional Tickit website where people buy and sell tickets for sporting events, shows, and concerts. You can load and explore this data set. For more information, see Working with the Tickit Data.

The following example queries the sample Tickit data to find the absolute value of the price per ticket minus the total price paid for each of the ticket listings.

SELECT ?listing (ABS(?priceper - ?total) AS ?absolute_value)
FROM <tickit>
WHERE {
  ?listing <priceperticket> ?priceper .
  ?listing <totalprice> ?total .
}
ORDER BY ?listing
LIMIT 10
listing       | absolute_value
--------------+----------------
listing1      |    1638.000000
listing10     |    2955.000000
listing100    |    3059.000000
listing1000   |     928.000000
listing10000  |    1350.000000
listing100001 |     410.000000
listing100002 |    5502.000000
listing100003 |    3146.000000
listing100004 |     368.000000
listing100006 |    6960.000000
10 rows