Nie je schopný zřetězit Hodnoty na základe Rôznych stĺpcov v prípade, keď vyhlásenie-snehová Vločka

0

Otázka

Dúfam, že sa máš dobre!..Snažím sa zřetězit hodnoty prípade, ak vyhlásenie na základe rôznych stĺpcov v vločka ..Prosím nájsť blok kód nižšie

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

Dostávam chybové hovorí, "Neočakávané ako"

Snažím sa budovať výsledný stĺpec výstup, ako tieto

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

Vďaka, Arun

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

Najlepšiu odpoveď

1

Čistejšie alternatívy, ktoré pridáva čiarky, ako je to potrebné, pomocou 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

Vďaka @Felipe...To naozaj pomáha!
user3369545

Prijmite prosím odpoveď, či je to odpoveď, ktorú ste chceli :)
Felipe Hoffa

Vďaka @Felipe!...Áno, som prijali odpoveď...
user3369545
1

V Snowflake, môžete použiť "||" na concat reťazcov, a nie "+":

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

Vďaka @ Eric Lin..je To naozaj užitočné....Môžete mi prosím dajte mi vedieť, ako odstrániť prvý znak prichádza ako comma
user3369545

Prepáčte, môžete mi prosím objasniť? Nemám plne pochopiť vaše vyššie uvedenú otázku.
Eric Lin

Ahoj Eric....V výstup pre výsledný som si čiarku v začiatku ...som sa pýtal, ako sa zbaviť comma...
user3369545

Je to preto, lebo tam bol "," v", Pacient nie je checked out " myslím, že?
Eric Lin

V iných jazykoch

Táto stránka je v iných jazykoch

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