sqrt
1. SQRT Function
=======sqrt
1. SQRT Function
>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62beThe SQRT function in H2 database is used to calculate the square root of a given number.
2. Syntax
The syntax for the SQRT function in H2 database is as follows:
SQRT(number)
Arguments
number
: The number for which the square root needs to be calculated. It should be a numeric value.
Return
- The SQRT function returns the square root of the given number.
3. Notes
- The SQRT function in H2 database expects a non-negative numeric value as input. If the input number is negative, the function will return
NULL
. - If the input number is not a number or exceeds the numeric range, the SQRT function will return
NULL
. - Ensure that the input number is of the correct datatype and within the valid range to avoid errors.
4. Examples
Here are a few examples demonstrating the usage of the SQRT function in H2 database:
Example 1 - Calculating the square root of a positive number:
SELECT SQRT(25) AS square_root;
Output:
square_root
-----------
5.0
Example 2 - Calculating the square root of a column value:
CREATE TABLE numbers (
id INT PRIMARY KEY,
value DOUBLE
);
INSERT INTO numbers VALUES (1, 16), (2, 9), (3, 25);
SELECT id, value, SQRT(value) AS square_root
FROM numbers;
Output:
id | value | square_root
---+-------+------------
1 | 16 | 4.0
2 | 9 | 3.0
3 | 25 | 5.0
5. Related Functions
- POW - Calculate power
- exp - Calculate exponential value