COALESCE
Sintassi
%%{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))
Scopo
La funzione SQL COALESCE esegue un'operazione di coalescenza, restituendo il primo valore non-null e, in caso contrario, null.
Vedi anche NVL.
Parametri:
- Posizione 1 (
ANY): un valore. - Posizione n (
ANY): altri valori.
Restituisce: il primo valore non-null come tipo di dati nella posizione 1.
Esempi
L'esempio seguente recupera il primo elemento non null:
select coalesce(-5, null, -3)
--------
-5
L'esempio seguente recupera il primo elemento non null:
select coalesce(null, null, -5, -3)
--------
-5
L'esempio seguente recupera il primo elemento non null. Si noti che il testo vuoto ha una semantica di tipo null su Invantive UniversalSQL:
select coalesce(null, '', 'answer 1', 'answer 2')
--------
answer 1