# MySQL STD() function

## STD() function

MySQL STD() function returns the population standard deviation of expression. The standard deviation is a statistical measure that quantifies the amount of variation or dispersion in a dataset.

It returns NULL if no matching row is found.

This function is useful in -

- It gives you an idea of how much individual values deviate from the average.
- A higher standard deviation indicates more spread-out data, while a lower standard deviation indicates more closely grouped data.
- When analyzing data, the standard deviation helps you understand the distribution of values and identify potential outliers or anomalies.
- In finance and risk analysis, standard deviation is used to measure the volatility or risk associated with investment returns or financial instruments.
- In manufacturing or quality control processes, standard deviation helps assess the consistency of product specifications and identify variations that may require corrective actions.
- Standard deviation is used to calculate confidence intervals, which provide a range within which a population parameter is likely to fall.
- You can use standard deviation to compare the variability of different datasets and assess their similarity or difference.

**Syntax:**

STD(expr);

Where **expr** is an expression.

**MySQL Version :** 8.0

**Example: MySQL STD() function **

The following MySQL statement will return the population standard deviation of 'total_cost' from 'purchase' table.

Sample table: purchase

Code:

```
-- This query calculates the standard deviation of the 'total_cost' column in the 'purchase' table.
SELECT STD(total_cost)
-- This statement selects the standard deviation of the 'total_cost' column.
FROM purchase;
-- This part of the query specifies the table from which data is being retrieved, which is 'purchase'.
```

**Explanation:**

- The purpose of this SQL query is to compute the standard deviation of the 'total_cost' values in the 'purchase' table.
- SELECT STD(total_cost): This part of the query selects the standard deviation of the 'total_cost' column. Standard deviation is a measure of the amount of variation or dispersion in a set of values.
- FROM purchase: This part specifies the table from which the data is being selected, which is the 'purchase' table.
- The query will return a single value, which is the standard deviation of the 'total_cost' values in the 'purchase' table. This value provides insight into the spread or dispersion of the 'total_cost' values in the dataset.

Output:

mysql> SELECT STD(total_cost) -> FROM purchase; +-----------------+ | STD(total_cost) | +-----------------+ | 315.392172 | +-----------------+ 1 row in set (0.23 sec)

**Previous:**
MIN()

**Next: **
STDDEV_POP()

**It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.**

https://www.w3resource.com/mysql/aggregate-functions-and-grouping/aggregate-functions-and-grouping-std().php

**Weekly Trends and Language Statistics**- Weekly Trends and Language Statistics