AppDividend
Latest Code Tutorials

SQL SQRT() Function Example | SQRT() in SQL

SQL SQRT() is an inbuilt function that is used for returning the square value of the specified number. SQL 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().

SQL SQRT()

The SQRT() in SQL function returns the square root of a number.

Syntax

SELECT SQRT (Number);

Parameters

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.

Examples

Query 1

Select SQRT (64);

Output

8

Query 2

Select SQRT (25);

Output

5

Query 3

Select SQRT (10);

Output

3.16227766016838

Explanation

As the return type of the SQRT function is float. So, the number was returned in decimal form.

Query 4

Select SQRT (0);

Output

0

Query 5 (Negative Value)

Select SQRT (-64);

Output

NULL

Explanation

Negative values will return NULL or “An invalid floating-point operation occurred.”

Query 6

Select SQRT (60+4);

Output

8

Explanation

Here, the arithmetic operation is performed inside the function, which is similar to 1st example.

SQL Server SQRT() Function

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. You can use the SELECT statement to find out the square root of any number as follows.

MySQL SQRT() Function

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.

See also

SQL TAN()

SQL CEILING()

SQL FLOOR()

SQL POWER()

SQL Log10()

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.