PostgreSQL ABS() function
ABS() function
The PostgreSQL abs() is used to return the absolute value of a number passed as an argument.
Uses of ABS() Function
- Mathematical Calculations: Compute the absolute value of positive and negative numbers.
- Data Analysis: Handle and transform numerical data, ensuring non-negative values.
- Financial Calculations: Ensure positive values in financial computations and reports.
- Statistical Operations: Use in statistical functions where magnitude without direction is required.
Syntax:
abs()
PostgreSQL Version: 9.3
Example: PostgreSQL ABS() function
Code:
SELECT ABS(115.36) AS "Absolute Value";
Output:
Absolute Value ---------------- 115.36 (1 row)
Example: PostgreSQL ABS() function using negative value
Code:
SELECT ABS(-115.36) AS "Absolute Value";
Sample Output:
Absolute Value ---------------- 115.36 (1 row)
Previous: Mathematical and Trigonomitecal functions Introduction
Next: ACOS function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/PostgreSQL/abs-function.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics