---
title: "Stddev Aggregate Function"
description: "Group function to find the standard deviation from a group of numerical values."
language: en
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/aggregate-functions/stddev-aggregate-function
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/aggregate-functions/stddev-aggregate-function
updated: 2026-10-25T00:00:00Z
license: https://documentation.invantive.eu/en/
---

## Syntax
```mermaid
%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart TD
    stdDevAggregateFunction_start((START))
    stdDevAggregateFunction_start --> stdDevAggregateFunction_0_0[STDDEV]:::quoted
    stdDevAggregateFunction_0_0 --> stdDevAggregateFunction_0_1["("]:::quoted
    stdDevAggregateFunction_0_1 --> stdDevAggregateFunction_0_2[DISTINCT]:::quoted
    stdDevAggregateFunction_0_1 --> stdDevAggregateFunction_0_2a[ALL]:::quoted
    stdDevAggregateFunction_0_2a --> stdDevAggregateFunction_0_3
    stdDevAggregateFunction_0_2 --> stdDevAggregateFunction_0_3[<a href="Invantive UniversalSQL/Grammar/Expression" class="internal-link">expression</a>]
    stdDevAggregateFunction_0_3 --> stdDevAggregateFunction_0_4[")"]:::quoted
    stdDevAggregateFunction_0_4 --> stdDevAggregateFunction_end((END))
```

## Purpose
Group function to find the standard deviation from a group of numerical values. The population standard deviation is calculated: the sum of the squared deviations from the average is divided by the number of values. The outcome for a group with one single value is 0. With `DISTINCT`, each unique value is included once. With `ALL`, the default, every value counts as often as it occurs; `ALL` is accepted from release 28.0.

## Examples
The following example calculates the standard deviation of the outstanding balances of the Wholesale customers, for instance to judge how evenly the credit risk is spread within the segment:
```sql
select stddev(cus.balance)
from   csvtable
       ( passing 'Acme Industries#Manufacturing#12500#50000|Bergmann GmbH#Manufacturing#0#25000|Carlson Ltd#Wholesale#2500#10000|Dubois SA#Wholesale#7500#10000|Everest BV#Services##5000'
         row delimiter '|'
         column delimiter '#'
         columns name         varchar2 position next
         ,       segment      varchar2 position next
         ,       balance      number   position next
         ,       credit_limit number   position next
       ) cus
where  cus.segment = 'Wholesale'

-------------------
2500
```
The following example calculates the standard deviation of the outstanding balances per customer segment, excluding customers without a balance:
```sql
select cus.segment
,      stddev(cus.balance)
from   csvtable
       ( passing 'Acme Industries#Manufacturing#12500#50000|Bergmann GmbH#Manufacturing#0#25000|Carlson Ltd#Wholesale#2500#10000|Dubois SA#Wholesale#7500#10000|Everest BV#Services##5000'
         row delimiter '|'
         column delimiter '#'
         columns name         varchar2 position next
         ,       segment      varchar2 position next
         ,       balance      number   position next
         ,       credit_limit number   position next
       ) cus
where  cus.balance is not null
group
by     cus.segment
order
by     cus.segment

-------------------
Manufacturing    6250
Wholesale        2500
```