Reference > Functions > Aggregate

VarP

  • 2005, 2008, 2012, 2014, 2016, 2017, 2019, 2022

Var (Population Variance) Aggregate Function

Use the VarP function to return the statistical variance for the population for all values in the specified expression.

Syntax

db.fx.VarP({expression})[.Distinct()]

Arguments

expression
The field expression, composite element, or function result to use in calculating the population variance.
Distinct()
Each unique value is considered in calculating the population variance value.

Returns

float

Examples

Select Statement

Select the variance for the population of product shipping weights.

float result = db.SelectOne(
        db.fx.VarP(dbo.Product.ShippingWeight)
    )
    .From(dbo.Product)
    .Execute();

Order By Clause

Select the variance for the population of product shipping weights ordered by the variance for the population of product shipping weights descending.

float result = db.SelectOne(
        db.fx.VarP(dbo.Product.ShippingWeight)
    )
    .From(dbo.Product)
    .OrderBy(db.fx.VarP(dbo.Product.ShippingWeight).Desc())
    .Execute();

Having Clause

Select the variance for the population of all products, grouped by product category type having a variance for the population greater than 1.

IEnumerable<float> results = db.SelectMany(
        db.fx.VarP(dbo.Product.ShippingWeight)
    )
    .From(dbo.Product)
    .GroupBy(dbo.Product.ProductCategoryType)
    .Having(db.fx.VarP(dbo.Product.ShippingWeight) > 1)
    .Execute();
Previous
Var

© 2024 dbExpression. All rights reserved.