Nie można połączyć wartości na podstawie różnych kolumn w przypadku, gdy operator-Śnieżynka

0

Pytanie

Mam nadzieję, że u ciebie wszystko dobrze!..Staram się łączyć wartości case when na podstawie różnych kolumn w snowflake ..Proszę, znajdź blok kodu poniżej

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

Otrzymuję komunikat o błędzie "Nagle, jak"

Staram się budować wyników wyjście kolumny w następujący sposób

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

Dziękuję Arun

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

Najlepsza odpowiedź

1

Bardziej czysta alternatywa, która dodaje przecinki w miarę potrzeby, za pomocą 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

Dziękuję @Felipe...To naprawdę pomaga!
user3369545

Proszę zapoznać się odpowiedź, jeśli to ta odpowiedź, którą chcesz :)
Felipe Hoffa

Dziękuję, @Felipe!...Tak, podjąłem odpowiedź...
user3369545
1

W Snowflake używasz "||" łączenia ciągów, 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

Dziękuję @ Eric Lin..To jest naprawdę przydatne....Proszę, daj mi znać, jak usunąć pierwszy znak, które przypada na przecinek
user3369545

Przepraszam, czy mógłby pan wyjaśnić, proszę? Nie do końca rozumiem twoje pytanie powyżej.
Eric Lin

Witam, Eric....Na wyjściu dla wypadkowego mam przecinka na początku ...pytałem, jak pozbyć się przecinka...
user3369545

To dlatego, że tam było", "w", Pacjent nie zwolniony", myślę?
Eric Lin

W innych językach

Ta strona jest w innych językach

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