Non in grado di concatenare i Valori sono Basati su Diverse colonne nel caso in cui la dichiarazione -Fiocco di neve

0

Domanda

Spero stai facendo bene!..Sto cercando di concatenare i valori del caso, quando la dichiarazione basata su colonne diverse fiocco di neve ..si Prega di trovare il blocco di codice riportato di seguito

select *,

case when checkouttime is null then ',Patient is not checked out' else '' END
+ case when primarypatientinsuranceid is null then ',No insurance information' else '' END
+ case when closedby is null then ',Encounter not signed off' else '' END
+ case when billingtabcheckeddate is null then ',Billing tab is not checked' else '' 
+ case when alreadyrouted is null then ',Missing slip already routed' else 'Valid Missing slip'

END as resultant

from final

Io sono sempre l'errore di dire che "Inaspettato"

Sto cercando di costruire la conseguente colonna di output come il seguente

Patient is not checked out/Billing tab is not checked
Missing slip already routed
Encounter not signed off/No insurance information /Billing tab is not checked
Valid Missing slip

Grazie, Arun

case snowflake-cloud-data-platform
2021-11-16 08:52:58
2

Migliore risposta

1

Un'alternativa più pulita che aggiunge una virgola se necessario, utilizzando array_to_string(array_construct_compact()):

with data as (
    select null checkouttime
        , 2 primarypatientinsuranceid
        , null closedby
        , 4 billingtabcheckeddate
        , 5 alreadyrouted
)

select array_to_string(array_construct_compact(
    iff(checkouttime is null, 'Patient is not checked out', null) 
    , iff(primarypatientinsuranceid is null, 'No insurance information', null)
    , iff(closedby is null, 'Encounter not signed off', null)
    , iff(billingtabcheckeddate is null, 'Billing tab is not checked', null)
    , iff(alreadyrouted is null, 'Missing slip already routed', 'Valid Missing slip')
    ), ',  ')
as resultant
from data
2021-11-16 21:53:34

Grazie @Felipe...Questo aiuta veramente!
user3369545

Si prega di accettare la risposta, se è la risposta che volevo :)
Felipe Hoffa

Grazie @Felipe!...Sì, ho accettato la risposta...
user3369545
1

In Fiocco di neve, è possibile utilizzare "||" per concat corde, non "+":

select 
case when true then ',Patient is not checked out' else '' END
|| case when false then ',No insurance information' else '' END
|| case when true then ',Encounter not signed off' else '' END
|| case when true then ',Billing tab is not checked' else '' END
|| case when false then ',Missing slip already routed' else 'Valid Missing slip' END 
as resultant;

https://docs.snowflake.com/en/sql-reference/functions/concat.html

2021-11-16 11:33:34

Grazie @ Eric Lin..Questo è veramente utile....Potete per favore fatemi sapere come rimuovere il primo personaggio proveniente da virgola (csv)
user3369545

Scusa, puoi precisare? Non ho capito bene la tua domanda di cui sopra.
Eric Lin

Ciao Eric....Nell'output risultante ottenere una virgola all'inizio ...mi stava chiedendo come sbarazzarsi di una virgola...
user3369545

Questo perché c'è stato un "," in", il Paziente non è controllato, credo?
Eric Lin

In altre lingue

Questa pagina è in altre lingue

Русский
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................