 Select person.pid as pid,

concat(ctitle.titlename,person.fname,' ',person.lname)as pname, person.birth as pbirth,

GetAgeymd(person.birth,CURDATE())as age,

person.idcard as idcard, person.hnomoi as hno, village.villno as villno,

case when GetAgemonth(person.birth,CURDATE())= '9' then "/" else '' end as ' 9เดือน', 
case when GetAgemonth(person.birth,CURDATE())= '18' then "/" else '' end as ' 18เดือน',
case when GetAgemonth(person.birth,CURDATE())= '30' then "/" else '' end as' 30เดือน',
case when GetAgemonth(person.birth,CURDATE())= '42' then "/" else '' end as ' 42เดือน'
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 substring(house.villcode,7,2)<>'00' 
and GetAgemonth(person.birth,CURDATE()) in ('9','18','30','42') 
order by villno;