Reference > Functions > Aggregate

StDevP

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

StDevP (Population Standard Deviation) Aggregate Function

Use the StDevP function to return the statistical standard deviation for the population for all values in the specified expression.

Syntax

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

Arguments

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

Returns

float

Examples

Select Statement

Select the standard deviation for the population of product shipping weights.

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

Order By Clause

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

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

Having Clause

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

IEnumerable<ProductCategoryType?> results = db.SelectMany(
        dbo.Product.ProductCategoryType
    )
    .From(dbo.Product)
    .GroupBy(dbo.Product.ProductCategoryType)
    .Having(db.fx.StDevP(dbo.Product.ShippingWeight) > 1)
    .Execute();
Previous
StDev

© 2024 dbExpression. All rights reserved.