sqlcmd.net validated sql reference

#statistics

Commands grouped around the same concept, pattern, or recurring problem.

7 commands with this tag Browse related patterns quickly
advanced aggregation MySQL MariaDB SQL Server PostgreSQL SQLite

Compute a Median or Arbitrary Percentile

Find the median or any percentile value using `PERCENTILE_CONT` in PostgreSQL, MariaDB, and SQL Server, or a window-function workaround in MySQL and SQLite.

advanced aggregation PostgreSQL

Compute Pearson Correlation and Covariance

Measure the strength of a linear relationship between two columns with `CORR(y, x)` and covariance with `COVAR_SAMP` / `COVAR_POP` in PostgreSQL.

intermediate aggregation MySQL MariaDB SQL Server PostgreSQL SQLite

Compute Standard Deviation and Variance

Measure how spread out values are with `STDDEV_SAMP` / `VAR_SAMP` in MySQL, MariaDB, and PostgreSQL, or `STDEV` / `VAR` in SQL Server.

advanced aggregation MariaDB SQL Server PostgreSQL

Detect Outliers Using the IQR Method

Flag values that fall outside the interquartile fence `[Q1 − 1.5 × IQR, Q3 + 1.5 × IQR]` using `PERCENTILE_CONT` in PostgreSQL, MariaDB, and SQL Server.

intermediate aggregation MySQL MariaDB SQL Server PostgreSQL SQLite

Find the Most Frequent Value (Statistical Mode)

Identify the value that appears most often in a column using `GROUP BY` with `ORDER BY COUNT(*) DESC LIMIT 1`, or with `MODE() WITHIN GROUP` in PostgreSQL.

advanced aggregation PostgreSQL

Fit a Linear Regression With REGR_SLOPE and REGR_INTERCEPT

Compute the least-squares slope, intercept, and R² of a linear regression directly in SQL using `REGR_SLOPE(y, x)`, `REGR_INTERCEPT(y, x)`, and `REGR_R2(y, x)` in PostgreSQL.

advanced windowing MySQL MariaDB SQL Server PostgreSQL SQLite

Normalise Values to Z-Scores

Rescale each row's value to the number of standard deviations it sits above or below the mean using `(value − AVG … OVER ()) / STDDEV_SAMP … OVER ()`.