# MySQL STDDEV_SAMP() function

## STDDEV_SAMP() function

MySQL STDDEV_SAMP() function returns the sample standard deviation of an expression ( the square root of VAR_SAMP()). Statistically, sample standard deviation quantifies the amount of variation or dispersion in a dataset for which you have a sample of the whole population.

It returns NULL if no matching rows are found.

This function is useful in -

- It's used when you have a sample of data and want to estimate the variability in the entire population.
- Data Analysis: The primary purpose of the STDDEV_SAMP() function is to accurately calculate the sample standard deviation.
- When comparing different samples or groups, STDDEV_SAMP() is used to assess the significance of differences between the groups.
- Sample standard deviation is used to calculate confidence intervals for population parameters based on sample data.
- STDDEV_SAMP() is used to explore the variation and distribution of data in sample datasets, helping in initial data analysis.
- Sample standard deviation is used in hypothesis testing to test the validity of assumptions and draw conclusions about population characteristics.

**Syntax:**

STDDEV_SAMP(expr);

Where expr is an expression.

**MySQL Version:** 8.0

**Example: MySQL STDDEV_SAMP() function **

The following statement returns the sample standard deviation of 'total_cost' from purchase table.

Sample table: purchase

Code:

```
SELECT STDDEV_SAMP(total_cost)
FROM purchase;
```

Output:

mysql> SELECT STDDEV_SAMP(total_cost) -> FROM purchase; +-------------------------+ | STDDEV_SAMP(total_cost) | +-------------------------+ | 345.494814 | +-------------------------+ 1 row in set (0.00 sec)

**Previous:**
STDDEV_POP()

**Next: **
STDDEV()

**Weekly Trends**- 100 Python Projects for Beginners with solution
- Mastering NumPy: 100 Exercises with solutions
- SQL Tutorial
- SQL Inner Join
- Python Exercises, Practice, Solution
- Python Interview Questions and Answers: Comprehensive Guide
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript HTML Form Validation
- Java Collection Exercises