MySQL aggregate function VARIANCE() returns population standard variance of the input field / data. It returns NULL if no matching row is found.
SELECT VARIANCE(mark),VAR_POP(mark), VAR_SAMP(mark) FROM `student`
Output is here
| VARIANCE(mark) | VAR_POP(mark) | VAR_SAMP(mark) |
|---|---|---|
| 272.1728395061727 | 272.1728395061727 | 282.6410256410255 |
Restrict decimal places by using FORMAT()
SELECT FORMAT(VARIANCE(mark),2) FROM `student`
Output is here
| FORMAT(VARIANCE(mark),2) |
|---|
| 272.17 |
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.