---
title: "Aggregatfunktion AVG"
description: "Gruppenfunktion zur Ermittlung des Durchschnittswerts aus einer Gruppe numerischer Werte."
language: de
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/de/docs/invantive-universalsql/grammar/aggregate-functions/avg-aggregate-function
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/aggregate-functions/avg-aggregate-function
updated: 2026-11-21T18:48:17Z
license: https://documentation.invantive.eu/de/
---

## Syntax

```mermaid
%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial' 
  }
}}%%
flowchart TD
    avgAggregateFunction_start((START))
    avgAggregateFunction_start --> avgAggregateFunction_0_0[AVG]:::quoted
    avgAggregateFunction_0_0 --> avgAggregateFunction_0_1["("]:::quoted
    avgAggregateFunction_0_1 --> avgAggregateFunction_0_3
    avgAggregateFunction_0_1 --> avgAggregateFunction_0_2[DISTINCT]:::quoted
    avgAggregateFunction_0_1 --> avgAggregateFunction_0_2a[ALL]:::quoted
    avgAggregateFunction_0_2a --> avgAggregateFunction_0_3
    avgAggregateFunction_0_2 --> avgAggregateFunction_0_3[<a href="Invantive UniversalSQL/General/Identifiers" class="internal-link">identifier</a>]
    avgAggregateFunction_0_3 --> avgAggregateFunction_0_4[")"]:::quoted
    avgAggregateFunction_0_4 --> avgAggregateFunction_end((END))
```

## Anwendung

Gruppenfunktion zur Ermittlung des Durchschnittswerts aus einer Gruppe numerischer Werte. Vorkommen von `null` werden ignoriert. Mit `DISTINCT` wird jeder eindeutige Wert einmal gemittelt, unabhängig davon, wie oft er vorkommt. Mit `ALL`, dem Standardwert, zählt jeder Wert so oft, wie er vorkommt; `ALL` wird ab Release 28.0 akzeptiert.

## Beispiele
Das folgende Beispiel ermittelt das durchschnittliche Kreditlimit über einen Kundenstamm von fünf Kunden:
```sql
select avg(cus.credit_limit)
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

-------------------
20000
```
Das folgende Beispiel ermittelt das durchschnittliche Kreditlimit pro Kundensegment, zum Beispiel um die Kreditrisikobereitschaft zwischen den Segmenten zu vergleichen:
```sql
select cus.segment
,      avg(cus.credit_limit)
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
group
by     cus.segment
order
by     cus.segment

-------------------
Manufacturing    37500
Services         5000
Wholesale        10000
```

