SELECT person.pid
,CONCAT(ctitle.titlename,person.fname,' ',person.lname) AS pname
,person.birth
,CONCAT(DATE_FORMAT(person.birth,'%d-%m-'),DATE_FORMAT(person.birth,'%Y')+543) AS birthh
,getAgeMonth(person.birth,CURDATE())as agemonth
,house.hno
,village.villno
,village.villname
FROM village
INNER JOIN house ON village.villcode = house.villcode
INNER JOIN person ON house.hcode = person.hcode
INNER JOIN ctitle on person.prename = ctitle.titlecode
LEFT JOIN persondeath ON person.pcucodeperson = persondeath.pcucodeperson AND person.pid = persondeath.pid
WHERE persondeath.pid IS NULL
AND village.villno != 0
GROUP BY person.pid 
HAVING getAgeMonth(person.birth,CURDATE()) BETWEEN '30' AND '84'
ORDER BY village.villno,house.hno*1;