SELECT person.pid
,concat(person.fname,' ',person.lname) as pname
,getAgeYearNum(person.birth,NOW()) AS 'YEAR'
,getAgeMonthNum(person.birth,NOW()) AS 'MONTH'
,getAgeDayNum(person.birth,CURDATE()) AS 'DAY'
,RIGHT(studenthealthnutrition.dateservice,2) AS วัน
,substr(studenthealthnutrition.dateservice,6,2) AS เดือน
,(LEFT(studenthealthnutrition.dateservice,4) + 543) AS ปีพศ
,studenthealthnutrition.weight
,studenthealthnutrition.hight
FROM studenthealthnutrition
INNER JOIN personstudent ON personstudent.pcucodeperson = studenthealthnutrition.pcucodeperson AND personstudent.pid = studenthealthnutrition.pid
INNER JOIN person ON person.pcucodeperson = personstudent.pcucodeperson AND person.pid = personstudent.pid
WHERE studenthealthnutrition.dateservice BETWEEN '2014-10-01' AND '2015-09-30'
ORDER BY personstudent.villcode,personstudent.schoolno;