SELECT
ncd_person_ncd_screen.pid,
person.fname,
person.lname,
CONCAT(DATE_FORMAT(ncd_person_ncd_screen.screen_date,'%d/%m/'),DATE_FORMAT(ncd_person_ncd_screen.screen_date,'%Y')+543) AS วันคัดกรองNCD,
CONCAT(DATE_FORMAT(persondeath.deaddate,'%d/%m/'),DATE_FORMAT(persondeath.deaddate,'%Y')+543) AS วันที่เสียชีวิต,
person.dischargetype
FROM person
INNER JOIN ncd_person_ncd_screen ON ncd_person_ncd_screen.pcucode = person.pcucodeperson AND ncd_person_ncd_screen.pid = person.pid
INNER JOIN persondeath ON person.pcucodeperson = persondeath.pcucodeperson AND person.pid = persondeath.pid
WHERE ncd_person_ncd_screen.screen_date > persondeath.deaddate;
