> ## Documentation Index
> Fetch the complete documentation index at: https://villagesql.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# vsql_statistics extension for MySQL

> The vsql_statistics community extension adds median, quartiles, t-tests, z-tests, ANOVA, chi-squared, covariance, skewness, and kurtosis to MySQL.

`vsql_statistics` adds statistical aggregates that MySQL does not have: median
and quartiles, t-tests, z-tests, one-way ANOVA, chi-squared, covariance,
skewness, kurtosis, mode, and four kinds of mean. Each one returns a JSON
object as a string, so a single call gives you every figure the test produces.
Cast the result with `CAST(... AS CHAR)` and read the fields you want with
`JSON_EXTRACT()`.

|                              |                                                                                     |
| ---------------------------- | ----------------------------------------------------------------------------------- |
| **Maintainer**               | [Ronald Bradford](https://github.com/ronaldbradford)                                |
| **Source and documentation** | [ronaldbradford/vsql-statistics](https://github.com/ronaldbradford/vsql-statistics) |
| **License**                  | GPL-2.0                                                                             |

<Note>
  A third party writes and maintains this extension. VillageSQL does not build,
  test, or ship it, and the description below follows the maintainer's own
  documentation. Read that documentation before you rely on it.
</Note>

## Install

Build it from the repository against SDK 0.0.4 or later, then install it into
the server:

```sql theme={null}
INSTALL EXTENSION vsql_statistics;
```

## What it adds

| Family                 | Functions                                                                             |
| ---------------------- | ------------------------------------------------------------------------------------- |
| Quartiles and outliers | `STATS_IQR` returns `q1`, `median`, `q3`, `iqr`, `lower_fence`, and `upper_fence`     |
| Two-sample t-test      | `STATS_TTEST`, `STATS_TTEST_GROUPS`                                                   |
| One-sample z-test      | `STATS_ZTEST`                                                                         |
| One-way ANOVA          | `STATS_ANOVA`                                                                         |
| Chi-squared            | `STATS_CHISQ_GOF`, `STATS_CHISQ_INDEP`                                                |
| Covariance             | `STATS_COVARIANCE`, population and sample                                             |
| Shape                  | `STATS_SKEWNESS`, `STATS_KURTOSIS`                                                    |
| Central tendency       | `STATS_MEAN` for trimmed, winsorized, geometric, and harmonic means, and `STATS_MODE` |

Every one returns its figures as a JSON string, so each needs a
`CAST(... AS CHAR)` before `JSON_EXTRACT()` reads a field. `STATS_IQR`, for
instance, puts the fences beside the quartiles, so finding outliers is one
aggregate rather than three passes over the data.

## See also

* [Available extensions](/docs/mysql-9.7/stable/extensions) — the full catalog
* [ronaldbradford/vsql-statistics](https://github.com/ronaldbradford/vsql-statistics) — source, the full function reference, and the known limitations
