SELECT l.hospcode,
chospcode.hospname,
COUNT(DISTINCT l.CID) as target
FROM chronic_no l
INNER JOIN chospcode on chospcode.hospcode = l.hospcode
WHERE
l.DIAGCODE LIKE "%J%"
OR
l.DIAGCODE LIKE "%I%"
or l.DIAGCODE LIKE "%E%"
GROUP BY l.HOSPCODE
UNION
select "รวมทั้งคัพ" as hospcode,"" as hosname
,COUNT(DISTINCT l.CID) as target
FROM chronic_no l
INNER JOIN chospcode on chospcode.hospcode = l.hospcode
WHERE
l.DIAGCODE LIKE "%J%"
OR
l.DIAGCODE LIKE "%I%"
or l.DIAGCODE LIKE "%E%"