Invantive-DokumentationTeil von Invantive Cloud
Invantive SupportforenAnmelden / Eintragen

COALESCE

Syntax

%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> COALESCE[COALESCE]:::quoted
    COALESCE --> End((END))

Anwendung

Die SQL-Funktion COALESCE führt eine Coalescing-Operation durch und gibt den ersten Wert zurück, der nicht non-null ist; andernfalls wird null zurückgegeben.

Siehe auch NVL.

Parameter:

  • Position 1 (ANY): ein Wert.
  • Position n (ANY): weitere Werte.

Gibt zurück: den ersten Wert, der nicht non-null ist, als Datentyp an der Position 1.

Beispiele

Das folgende Beispiel ruft das erste Element ab, das nicht non-null ist:

select coalesce(-5, null, -3)

--------
-5

Das folgende Beispiel ruft das erste Element ab, das nicht non-null ist:

select coalesce(null, null, -5, -3)

--------
-5

Das folgende Beispiel ruft das erste Element ab, das nicht non-null ist. Bitte beachten Sie, dass der leere Text in Invantive UniversalSQL die Semantik von null hat:

select coalesce(null, '', 'answer 1', 'answer 2')

--------
answer 1