Não é capaz de concatenar Valores com Base em Diferentes colunas em caso de declaração -floco de Neve

0

Pergunta

Espero que você está fazendo bem!..Eu estou tentando concatenar valores de caso quando a instrução com base em diferentes colunas em floco de neve ... por Favor, encontrar o bloco de código abaixo

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

Estou recebendo o erro dizendo que "o Inesperado como"

Estou tentando construir a coluna de saída, conforme a seguinte

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

Obrigado, Arun

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

Melhor resposta

1

Um aspirador de alternativas que adiciona vírgulas, conforme necessário, usando 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

Obrigado @Felipe...Isso realmente ajuda!
user3369545

Por favor, aceite a resposta, se é a resposta que você queria :)
Felipe Hoffa

Obrigado @Felipe!...Sim eu aceito a resposta...
user3369545
1

Em floco de Neve, você pode usar "||" para concat cadeias, não "+":

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

Obrigado @ Eric Lin..Isso é realmente útil....Pode você por favor, deixe-me saber como remover o primeiro personagem vindo como vírgula
user3369545

Desculpe, por favor você pode esclarecer? Eu não entendemos sua pergunta acima.
Eric Lin

Oi Eric....Na saída resultante eu recebo uma vírgula no início ...eu estava perguntando a respeito de como se livrar da vírgula...
user3369545

Isso porque houve um "," em", o Paciente não está com check-out' eu acho?
Eric Lin

Em outros idiomas

Esta página está em outros idiomas

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