# MySQL SQRT() function

## SQRT() function

MySQL SQRT() returns the square root of a non-negative number of the argument.

This function is useful in -

- In geometry and trigonometry, SQRT() is frequently used to calculate distances, lengths, and dimensions of shapes and figures.
- SQRT() is used to compute the square root of variances, which are key measures in statistics for understanding the spread or dispersion of data points.
- Engineers and physicists use SQRT() to analyze and model physical systems.
- In finance and economics, SQRT() can be used to calculate standard deviations, which are crucial in risk assessment, portfolio management, and investment strategies.
- In many scientific and engineering applications, it's important to estimate or quantify errors or uncertainties.
- SQRT() is useful for validating input data or for checking the validity of certain calculations, particularly when dealing with physical or real-world measurements.
- SQRT() can be employed in data preprocessing or feature engineering steps where scaling or normalizing data is necessary.
- In computer graphics and visualization, SQRT() can be used to calculate dimensions, distances, and sizes of objects, as well as to handle transformations.

**Syntax:**

SQRT(X)

Where **X** is a number

**Syntax Diagram:**

**MySQL Version: 8.0**

**Pictorial presentation of MySQL SQRT() function**

**Example of MySQL SQRT() function**

Code:

```
SELECT SQRT(25);
```

**Explanation:**

The above statement will return the square root of the given number 25.

Output:

mysql> SELECT SQRT(25); +----------+ | SQRT(25) | +----------+ | 5 | +----------+ 1 row in set (0.00 sec)

**Example: SQRT() function using negative value**

Code:

```
SELECT SQRT(-25);
```

**Explanation:**

The above statement will return NULL because the value of the argument (-25) is negative.

Output:

mysql> SELECT SQRT(-25); +-----------+ | SQRT(-25) | +-----------+ | NULL | +-----------+ 1 row in set (0.00 sec)

**Weekly Trends**- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join