When deyimi-Snowflake durumunda Farklı sütunlara dayalı Değerler birleştirilemiyor

0

Soru

Umarım iyi gidiyorsundur!..Snowflake'deki farklı sütunlara dayanan case when deyiminin değerlerini birleştirmeye çalışıyorum ..Lütfen aşağıdaki kod bloğunu bulun

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

"Beklenmeyen"diyerek hata alıyorum.

Sonuç sütun çıktısını aşağıdaki gibi oluşturmaya çalışıyorum

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

Teşekkürler, Arunname

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

En iyi cevabı

1

Gerektiğinde virgül ekleyen daha temiz bir alternatif 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

Teşekkürler @ Felipe...Bu gerçekten yardımcı oluyor!
user3369545

İstediğiniz cevap buysa lütfen cevabı kabul edin :)
Felipe Hoffa

Teşekkürler @ Felipe!...Evet cevabı kabul ettim...
user3369545
1

Snowflake'de, " + "değil, dizeleri birleştirmek için" | | "kullanırsınız.:

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

Teşekkürler @ Eric Lin..Bu gerçekten yardımcı oldu....Virgül olarak gelen ilk karakteri nasıl kaldıracağımı lütfen bana bildirir misiniz
user3369545

Pardon, açıklığa kavuşturabilir misiniz? Yukarıdaki sorunuzu tam olarak anlamıyorum.
Eric Lin

Merhaba Eric....In sonuç için çıktı, başlangıçta virgül alıyorum ...Virgülden nasıl kurtulacağımı soruyordum...
user3369545

Çünkü bir", "girişi vardı, Hasta kontrol edilmedi" Sanırım?
Eric Lin

Diğer dillerde

Bu sayfa diğer dillerde

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