Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs

MySQL VAR_POP Function

by suresh

MySQL VAR_POP is one of the Aggregate Function, which calculates the Standard Variance of total records (or rows) selected by the SELECT Statement.

MySQL VAR_POP Formula

The VARIANCE Function is the synonyms for the standard VAR_POP function. So, you can use this function also. The mathematical formulas behind the VAR_POP to calculate the standard variance in MySQL is

--Calculating the Mean or Average
Mean = Sum of each individual / Total number of items

--Calculating the Variance
Variance = ( (OriginalValue – Mean)² + (OriginalValue – Mean)² +.... ) / Total number of items

The basic syntax behind the VARIANCE, VAR_POP in MySQL is

-- MySQL VARIANCE example
SELECT VARIANCE(Column_Name)
FROM Source;

-- MySQL VAR_POP example
SELECT VAR_POP(Column_Name)
FROM Source;

In this article, we show you, How to write VARIANCE, VAR_POP functions to calculate the standard Variance with example. For this, We are going to use the below-shown MySQL data.

MySQL VAR_POP Example 1

MySQL VAR_POP Example

The VARIANCE, VAR_POP functions returns the Standard Variance of the total number of records present in the specified column. For example, below query will calculate the Standard Variance of total records present in Yearly_Income from Customer details table.

-- MySQL VARIANCE example
SELECT VARIANCE(Yearly_Income) AS `Standard income Variance`
FROM customerdetails;

-- MySQL VAR_POP example
SELECT VAR_POP(Yearly_Income) AS `Standard income Variance`
FROM customerdetails;
MySQL VAR_POP Function Example 1

MySQL VAR_POP Group By Example

In general, VAR_POP or VARIANCE functions calculate the Standard Variance of products belongs to a particular category or color, etc. In these situations, we can use GROUP BY Clause to group the products by color or category. And next, we use VAR_POP Aggregate Function to calculate the Standard Variance.

-- MySQL VARIANCE, and VAR_POP Function Examples
USE company;
SELECT  Profession,
        VAR_POP(Yearly_Income),
        VARIANCE(Yearly_Income)
FROM customerdetails
GROUP BY Profession;

Above VAR_POP and Variance SELECT Statement query group the Customers by their Profession, and determine their Standard Variance

MySQL VAR_POP Function Example 2

We are taking the Software Developer profession.

–Calculating Mean
Mean = (70,000 + 79,000) / 2
Mean = 74500

–Calculating Variance
Variance = (70000 – 74500)² + (79000 – 74500)² / 2
Variance = 20,250,000

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions

Copyright © 2021 · All Rights Reserved by Suresh

About Us | Contact Us | Privacy Policy