---
title: "Funci\u00F3n de agregaci\u00F3n Stddev"
description: "Funci\u00F3n de grupo para encontrar la desviaci\u00F3n est\u00E1ndar de un grupo de valores num\u00E9ricos."
language: es
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/es/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-11-21T18:48:40Z
license: https://documentation.invantive.eu/es/
---

## Sintaxis
```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))
```

## Propósito
Función de grupo para encontrar la desviación estándar de un grupo de valores numéricos. Se calcula la desviación estándar poblacional: la suma de las desviaciones al cuadrado respecto a la media se divide entre el número de valores. El resultado para un grupo con un único valor es 0. Con `DISTINCT`, cada valor único se incluye una sola vez. Con `ALL`, el valor por defecto, cada valor cuenta tantas veces como aparece; `ALL` se acepta desde la versión 28.0.

## Ejemplos
El siguiente ejemplo calcula la desviación estándar de los saldos pendientes de los clientes mayoristas, por ejemplo para valorar lo uniformemente repartido que está el riesgo de crédito dentro del segmento:
```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
```
El siguiente ejemplo calcula la desviación estándar de los saldos pendientes por segmento de cliente, excluyendo los clientes sin saldo:
```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
```

