SELECT
person.pid AS pid,
concat(ctitle.titlename,person.fname,' ',person.lname)as pname,
person.birth AS pbirth,
GetAgeYearNum(person.birth,CURRENT_DATE)as age,
person.idcard AS pcid,
person.sex AS sex,
person.hnomoi AS hno,
village.villno AS village_villno,
village.villname AS village_villname
FROM
person INNER JOIN ctitle ON person.prename = ctitle.titlecode
INNER JOIN house ON person.pcucodeperson = house.pcucode
AND person.hcode = house.hcode
INNER JOIN village ON house.pcucode = village.pcucode
AND village.villcode = house.villcode
WHERE
person.typelive IN ('1','3')
and person.pid not in (SELECT persondeath.pid FROM persondeath)
and person.birth between '2011-12-08' and '2012-01-11'
and SUBSTRING(house.villcode,7,2)<>'00'
AND nation='99'
order BY village.villno,person.hnomoi*1;