website logo
⌘K
🏠Homepage
👋Introduction
Key Concepts & Architecture
🚀Getting Started
👨‍💻SQL Reference
SQL Queries
SQL Clauses
SQL Data Types
SQL Functions
Schema
🚨Error Handling
🆚Differences Between Oxla vs. PostgreSQL
Docs powered by archbee 

ABS

7min

This article will show you how to calculate the absolute value using the ABS() function.

Overview

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

The input and return types we support can be seen in the table below.

Document image


✅ The ABS() function returns a value that is the same as the input types.

Examples

#Case 1: Basic Absolute

The following example will calculate the absolute value of a negative floating number:

Select abs
|
SELECT ABS(-22.50) AS "Absolute";


It will return the floating number without the negative value:

Output
|
+-----------+
| Absolute  |
+-----------+
| 22.50     |
+-----------+


#Case 2: Absolute with an expression

The following example calculates the absolute value of an expression i.e., the subtraction operation:

Select abs
|
SELECT ABS( 150 - 250 ) AS "Absolute";


We know that the result of (150 - 250) is -100, but in this case, we’re using an ABS() function to get an absolute number so that the result will ignore the negative value.

Output
|
+-----------+
| Absolute  |
+-----------+
| 100       |
+-----------+




Updated 11 May 2023
Did this page help you?
Yes
No
PREVIOUS
AVG
NEXT
COUNT
Docs powered by archbee 
TABLE OF CONTENTS
Overview
Examples
#Case 1: Basic Absolute
#Case 2: Absolute with an expression

Dedicated to data analytics that provides 10x faster execution of analytical queries than current state of the art solutions. We are launching SOON! Join the waiting list for more info.




©2022 Oxla