MySQL VARIANCE() Function: Measure population variance

VARIANCE() measures the average squared deviation from the mean across a population of values. It is equivalent to VAR_POP().

VARIANCE(): Quick SQL Example

Run this SELECT query directly in MySQL or phpMyAdmin. It uses fixed inputs so you can verify the result without creating a table.

SELECT ROUND(VAR_POP(v), 2) AS population_variance FROM (SELECT 2 AS v UNION ALL SELECT 4 UNION ALL SELECT 6) AS sample;
population_variance
2.67
On this page — Show page sectionsHide page sections

More SQL Examples and Explanations

Variance query

VARIANCE() returns population variance and is a synonym for VAR_POP(). Use VAR_SAMP() when you need sample variance.

The examples use the student table SQL dump.

SELECT VARIANCE(mark), VAR_POP(mark), VAR_SAMP(mark)
FROM student;
VARIANCE(mark)VAR_POP(mark)VAR_SAMP(mark)
272.1728395061727272.1728395061727282.6410256410255

Using FORMAT()

Use FORMAT() to control displayed decimal places.

SELECT FORMAT(VARIANCE(mark), 2)
FROM student;
FORMAT(VARIANCE(mark), 2)
272.17

How to Interpret the Result

VAR_SAMP() uses the sample denominator (n−1). Choose the function based on the statistical population represented.

Common Question

Is VARIANCE() the same as VAR_SAMP()?
No. VARIANCE() means population variance in MySQL; VAR_SAMP() calculates sample variance.

↑ Back to top




Subscribe to our YouTube Channel here



plus2net.com




SQL Video Tutorials










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer