PostgreSQL Tutorial

  • Home
  • Stored Procedures
  • Triggers
  • Views
  • Interfaces
    • PostgreSQL PHP
    • PostgreSQL Python
    • PostgreSQL JDBC
  • Functions
    • Aggregate Functions
    • Date / Time Functions
    • String Functions
    • Math Functions
Home / PostgreSQL Math Functions / PostgreSQL ABS Function

PostgreSQL ABS Function

The PostgreSQL ABS() function returns the absolute value of a number.

Syntax

The following illustrates the syntax of the ABS() function:

1
ABS(numeric_expression)

Arguments

The ABS() function requires one argument:

1) numeric_expression

The numeric_expression can be a number or a numeric expression that evaluates to a number.

Return Value

The ABS() function returns a value whose data type is the same as the input argument.

Examples

The following example shows how to use the ABS() function to calculate the absolute value of a number:

1
SELECT ABS(-10.25)

The result is:

1
10.25

The following statement uses an expression for the ABS() function:

1
SELECT ABS( 100 - 250 );

Here is the result:

1
150

Besides the ABS() function, you can use the absolute operator @, for example:

1
SELECT @ -15

It returned 15 as expected.

1
-15

In this tutorial, you have learned how to use the PostgreSQL ABS() function to calculate the absolute value of a number.

Next Tutorial: PostgreSQL ROUND Function

PostgreSQL Math Functions

  • ABS
  • CEIL
  • MOD
  • FLOOR
  • ROUND
  • TRUNC

About PostgreSQL Tutorial

PostgreSQLTutorial.com is a website dedicated to developers and database administrators who are working on PostgreSQL database management system.

We constantly publish useful PostgreSQL tutorials to keep you up-to-date with the latest PostgreSQL features and technologies. All PostgreSQL tutorials are simple, easy-to-follow and practical.

Recent PostgreSQL Tutorials

  • PostgreSQL ANY Operator
  • PostgreSQL EXISTS
  • How To Delete Duplicate Rows in PostgreSQL
  • PostgreSQL TO_CHAR Function
  • PostgreSQL TO_NUMBER Function
  • PostgreSQL TO_TIMESTAMP Function
  • PostgreSQL CEIL Function
  • PostgreSQL MOD Function
  • PostgreSQL FLOOR Function
  • PostgreSQL ABS Function

More Tutorials

  • PostgreSQL Cheat Sheet
  • PostgreSQL Administration
  • PostgreSQL PHP
  • PostgreSQL Python
  • PostgreSQL JDBC
  • PostgreSQL Resources

Site Info

  • Home
  • About Us
  • Contact Us
  • Privacy Policy

Copyright © 2017 by PostgreSQL Tutorial Website. All Rights Reserved.