0
我有以下查詢:Case語句
-- COLUMN SELECTION
-- INITIAL ENCOUNTERS
SELECT pt_no AS 'INITIAL ENCOUNTER'
, Episode_No AS 'INITIAL EPISODE NO'
, med_rec_no, pt_name AS 'PT NAME'
, adm_src_desc AS 'INITIAL ADM SOURCE'
, adm_date AS 'INITIAL ADM DATE'
, dsch_date AS 'INITIAL DISC DATE'
, DATEDIFF(DD,ADM_DATE,DSCH_DATE) AS 'INITIAL LOS'
, pyr1_co_plan_cd AS 'INITIAL INSURANCE'
, mdc_name AS 'INITIAL MDC'
, clasf_desc AS 'INITAL CLASF'
, Admit_Adm_Dr_Name AS 'INITIAL ADMIT DR'
, Admit_Atn_Dr_Name AS 'INITIAL ATTENDING'
, Days_To_Readmit
,
-- READMISSION ENCOUNTERS
B_Pt_No AS 'READMIT ENCOUNTER'
, B_Episode_No AS 'READMIT EPISODE NO'
, B_Adm_Src_Desc AS 'READMIT SOURCE'
, B_Adm_Date AS 'READMIT DATE'
, B_Dsch_Date AS 'READMIT DISC DATE'
, DATEDIFF(DD,B_ADM_DATE,B_DSCH_DATE) AS 'READMIT LOS'
, B_Pyr1_Co_Plan_Cd AS 'READMIT INSURANCE'
, B_Mdc_Name AS 'READMIT MDC'
, B_Clasf_Desc AS 'READMIT CLASF'
, B_Readm_Adm_Dr_Name AS 'READMIT ADMITTING DR'
, B_Readm_Atn_Dr_Name AS 'READMIT ATTENDING DR'
, B_Days_To_Readmit
-- DB USED
FROM smsdss.c_readmissions_v
-- FILTERS USED
WHERE adm_date BETWEEN '2012-05-01' AND '2013-04-30'
AND adm_src_desc != 'SCHEDULED ADMISSION'
AND pt_no < 20000000
AND B_Adm_Src_Desc != 'SCHEDULED ADMISSION'
AND B_Pt_No < 20000000
AND B_Dsch_Date IS NOT NULL
--AND pyr1_co_plan_cd IN (
--CASE WHEN pyr1_co_plan_cd = '*' THEN 'Self Pay'
-- ELSE pyr1_co_plan_cd
--END
--)
--AND B_Pyr1_Co_Plan_Cd IN (
--CASE WHEN B_Pyr1_Co_Plan_Cd = '*' THEN 'SELF PAY'
-- ELSE B_Pyr1_Co_Plan_Cd
--END
--)
在結果pyr1_co_plan_cd
和B_pyr1_plan_cd
既可以等於*
我想用一個CASE
聲明爲了強制*
結果爲'Self Pay'
我現在擁有CASE語句的方式最終將踢出賬號我是tryi以強制該案件,這意味着這些案件不再打我的結果集。
我沒有如here
嘗試使用WHERE子句中的CASE語句謝謝