SQL SQRT() Function: The Complete Guide
The SQRT() in the SQL function returns the square root of a number.
SQL SQRT() is a built-in function used to return the square value of the specified number. The SQRT() returns the square root of a given value in the argument. An expression is a numeric value or numeric data type. All of the above platforms support the SQL syntax of SQRT().
SELECT SQRT (Number);
Number: A positive number whose square root is to be calculated. It can also be an expression of float or a type that can be implicitly converted to float.
Select SQRT (64);
Select SQRT (25);
Select SQRT (10);
As the return type of the SQRT function is float. So, the number was returned in decimal form.
Select SQRT (0);
Query 5 (Negative Value)
Select SQRT (-64);
Negative values will return NULL or “An invalid floating-point operation occurred.”
Select SQRT (60+4);
Here, the arithmetic operation is performed inside the function, similar to the 1st example.
SQL Server SQRT()
SQRT() function in SQL Server returns the square root of a number. SQL SQRT() function is used to find out the square root of any number. For example, you can use the SELECT statement to find out the square root of any number.
MySQL SQRT() returns the square root of a non-negative number of the argument. The above statement will return the square root of the given number, 25. The above statement will return NULL because the value of the argument (-25) is negative.