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 

SQRT

12min

This article will guide you on how to use the SQRT() function, with its syntax and examples.

Overview

The SQRT() function returns the square root of a given positive number.

Syntax

The syntax for the SQRT() function in Oxla is:

Syntax
|
SQRT(x)


The SQRT() function requires one argument:

  • x: A positive number or an expression that evaluates to a positive number.

Examples

# Case 1: SQRT() function with a positive argument

The following example demonstrates how the SQRT() function can be used to find the square root of a positive integer:

Select SQRT
|
SELECT SQRT(81);


You will get the following result:

Output
|
+-----+
| f   |
+-----+
| 9   |
+-----+


# Case 2: SQRT() function with an expression

Let’s look at an example of using the SQRT() function to find the square root of the result of an expression.

Select SQRT
|
SELECT SQRT(60 + 4);


The result of the above statement is the square root of 64:

Output
|
+-----+
| f   |
+-----+
| 8   |
+-----+


# Case 3: SQRT() function with double precision result

In addition to integers, Oxla also supports the calculation of square roots with floating-point numbers as the outcome. For further details, please refer to the statement below:

Select SQRT
|
SELECT SQRT(70);


The output of the statement above is 8.3666, which is the square root of 70 with double precision, as demonstrated below:

Output
|
+----------+
| f        |
+----------+
| 8.3666   |
+----------+


# Case 4: SQRT() function with a negative argument

The following example demonstrates how attempting to use the SQRT() function with a negative value will return an error:

Select SQRT
|
SELECT SQRT(-25);


As the SQRT() function only accepts positive numbers, you will get a NaN (Not a Number) result for the square root of -25, as shown below:

Output
|
+-------+
| f     |
+-------+
| NaN   |
+-------+




Updated 11 May 2023
Did this page help you?
Yes
No
PREVIOUS
ABS
NEXT
RANDOM
Docs powered by archbee 
TABLE OF CONTENTS
Overview
Syntax
Examples
# Case 1: SQRT() function with a positive argument
# Case 2: SQRT() function with an expression
# Case 3: SQRT() function with double precision result
# Case 4: SQRT() function with a negative argument

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