Help Center/ AI DataLake/ Spark reference/ Built-In Functions/ Aggregate Functions/ variance/var_pop
Updated on 2026-11-06 GMT+08:00
variance/var_pop
Function
The variance/var_pop function is used to return the population variance of a column.
Syntax
variance(col), var_pop(col)
Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| col | Yes | A column with numeric data type. Columns of other types return NULL. |
Return Values
Returns a value of type DOUBLE.
Examples
- Calculate the variance of all items inventory. Example command:
select variance(items) from warehouse; -- Equivalent to the following statement. select var_pop(items) from warehouse;
Result:
_c0 203.42352
- Used with GROUP BY to group all items by warehouse (warehouseId) and calculate the variance of items inventory within the same group. Example command:
select warehouseId, variance(items) from warehouse group by warehouseId; -- Equivalent to the following statement. select warehouseId, var_pop(items) from warehouse group by warehouseId;
Result:
warehouseId _c1 city1 19.23124 city2 17.23344 city3 12.43425
Parent topic: Aggregate Functions
What is your overall rating for this page?
0
1
2
3
4
5
6
7
8
9
10
Very dissatisfiedVery satisfied
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot