SELECT
person.pid as 'HN',
person.fname as 'ชื่อ',
person.lname as 'นามสกุล',
person.hnomoi as 'บ้านเลขที่',
person.mumoi as 'หมู่ที่',
getAgeYearNum (birth,CURDATE()) as 'อายุ',
person.typelive
FROM
person
INNER JOIN ncdpersonscreenall ON person.pcucodeperson = ncdpersonscreenall.pcucode AND person.pid = ncdpersonscreenall.pid
WHERE
person.typelive IN ( 1,3 )
AND person.pid NOT IN (select persondeath.pid from persondeath)
AND getAgeYearNum (birth,CURDATE()) >= '35'
AND person.pid NOT IN (select ncdpersonscreenall.pid from ncdpersonscreenall WHERE ncdpersonscreenall.screen_date BETWEEN '2013-10-01' AND '2014-03-30')
GROUP BY
person.pid;