B I G B I R D ‘ S

Ortho

SELECT
CONCAT(c.hname,': ',c.splevel)AS hosp,
COUNT(DISTINCT CASE WHEN t.CID<>'' AND t.DISCHTYPE<>4 AND t.BYEAR=2557 THEN t.cid END) AS 'A_2557',
COUNT(DISTINCT CASE WHEN t.CID<>'' AND t.BYEAR=2557 THEN t.cid END) AS 'B_2557',
COUNT(DISTINCT CASE WHEN t.CID<>'' AND t.DISCHTYPE<>4 AND t.BYEAR=2558 THEN t.cid END)AS 'A_2558',
COUNT(DISTINCT CASE WHEN t.CID<>'' AND t.BYEAR=2558 THEN 1 ELSE 0 END)AS 'B_2558',
COUNT(DISTINCT CASE WHEN t.CID<>'' AND t.DISCHTYPE<>4 AND t.BYEAR=2559 AND t.Q=1 THEN t.cid END)AS 'A_59_Q1',
COUNT(DISTINCT CASE WHEN t.CID<>'' AND t.Q=1 THEN 1 ELSE 0 END)AS 'B_59_Q1',
COUNT(DISTINCT CASE WHEN t.CID<>'' AND t.DISCHTYPE<>4 AND t.BYEAR=2559 AND t.Q=2 THEN t.cid END)AS 'A_59_Q2',
COUNT(DISTINCT CASE WHEN t.CID<>'' AND t.Q=2 THEN 1 ELSE 0 END)AS 'B_59_Q2',
COUNT(DISTINCT CASE WHEN t.CID<>'' AND t.DISCHTYPE<>4 AND t.BYEAR=2559 AND t.Q=3 THEN t.cid END)AS 'A_59_Q3',
COUNT(DISTINCT CASE WHEN t.CID<>'' AND t.Q=3 THEN 1 ELSE 0 END)AS 'B_59_Q3',
COUNT(DISTINCT CASE WHEN t.CID<>'' AND t.DISCHTYPE<>4 AND t.BYEAR=2559 AND t.Q=4 THEN t.cid END)AS 'A_59_Q4',
COUNT(DISTINCT CASE WHEN t.CID<>'' AND t.Q=4 THEN 1 ELSE 0 END)AS 'B_59_Q4',
COUNT(DISTINCT CASE WHEN t.CID<>'' AND t.DISCHTYPE<>4 AND t.BYEAR=2560 AND t.Q=1 THEN t.cid END)AS 'A_60_Q1',
COUNT(DISTINCT CASE WHEN t.CID<>'' AND t.Q=1 THEN t.cid END)AS 'B_60_Q1'
FROM t_ortho t
LEFT JOIN ccmihosp c ON c.hcode = t.HOSPCODE
WHERE t.DIAGCODE IN('S4200','S6250','S6260','S9240','S9250','S5250','S5260','S5280')
AND c.byear=2560 AND c.chwcode=42
GROUP BY HOSPCODE;
แสดงความคิดเห็น (0)
ใหม่กว่า เก่ากว่า