SELECT
' ' AS `ลำดับที่`,
CONCAT(ctitle.titlename,person.fname,' ',person.lname) AS `ชื่อ - สกุล`,
person.birth AS `ว.ด.ป.เกิด`,
getAgeMonthNum(birth,CURDATE()) AS `อายุ`,
person.idcard AS `เลขประชาชน`,
house.hno AS `ที่อยู่`,
person.father,
person.mother
FROM
person
INNER JOIN ctitle ON ctitle.titlecode = person.prename
INNER JOIN house ON person.pcucodeperson = house.pcucode AND person.hcode = house.hcode
INNER JOIN village ON house.pcucode = village.pcucode AND house.villcode = village.villcode
WHERE
person.birth BETWEEN '2014-05-01' AND '2014-05-31'
and right(village.villcode,2) <> '00'
and person.pid not in (select persondeath.pid from persondeath)
and person.typelive IN ('1', '3') and person.dischargetype = '9';