In SQLite, the sqrt() function returns the square root of a number.
Syntax
sqrt(x)Arguments
x
x is the number that you want to calculate the square root. x can be a literal number, a numeric expression, or a table column. Furthermore, x must be 0 or positive.
Return type
real
The sqrt() function returns the square root of an input number as real.
If x is NULL or negative, the sqrt() function returns NULL.
If x is not a number, the sqrt() function implicitly converts it to a number before calculating the square root. If the conversion fails, the function will also return NULL.
Examples
The following statement uses the sqrt() function to calculate the square root of 64:
SELECT sqrt(64) square_root;Output:
square_root
-----------
8.0Code language: CSS (css)The following statement uses the sqrt() function to calculate the square root of the string ‘100’:
SELECT sqrt(100) square_root;Output:
square_root
-----------
10.0Code language: CSS (css)In this example, the sqrt() function converts the string '100' to the number 100 and returns the square root of 100, which is 10.