我有一個病例陳述,例如下面的陳述中有多個結果。不幸的是,由於前三項成果得到滿足,其他選項被忽略。有沒有考慮到所有結果的說法?CASE聲明有多個結果 - 忽略了一些結果
,CASE WHEN T.T1_HoNOSCA_Score IS NULL THEN 'Missing T1'
WHEN T.T2_HoNOSCA_Score IS NULL THEN 'Missing T2'
WHEN T.T1HonosValidity IN ('NULL','Invalid 9','Invalid Null')
OR T.T2_HonosValidity IN ('NULL','Invalid 9','Invalid Null') THEN 'Invalid Data'
WHEN T.T1_HoNOSCA_Score IS NULL AND T.T2_HoNOSCA_Score IS NULL THEN 'Missing T1 & T2'
WHEN T.T1_HoNOSCA_Score IS NULL AND T.T1HonosValidity IN ('NULL','Invalid 9','Invalid `enter code here`Null')
OR T.T2_HonosValidity IN ('NULL','Invalid 9','Invalid Null') THEN 'Missing T1 & Invalid Data'
WHEN T.T2_HoNOSCA_Score IS NULL AND T.T1HonosValidity IN ('NULL','Invalid 9','Invalid Null')
OR T.T2_HonosValidity IN ('NULL','Invalid 9','Invalid Null') THEN 'Missing T2 & Invalid Data'
WHEN T.T1_HoNOSCA_Score IS NULL AND T.T2_HoNOSCA_Score IS NULL AND T.T1HonosValidity IN ('NULL','Invalid 9','Invalid Null')
OR T.T2_HonosValidity IN ('NULL','Invalid 9','Invalid Null') THEN 'Missing T1 & T2 & Invalid Data'
ELSE NULL END AS Data_Quality_Type
請添加示例數據和預期的輸出。 –
更改'when..then'從句的順序,讓更復雜的句子先到達。 –
只要第一個CASE得到滿足,其他人就不會被檢查。記住這一點並重新設計您的查詢。要麼改變條款的順序 - 要麼在CASE中使用CASE。 –