SELECT
village.village_moo,
village.village_name,
sum(IF(person.house_regist_type_id=1,1,0)) as typearea1,
sum(IF(person.house_regist_type_id=2,1,0)) as typearea2,
sum(IF(person.house_regist_type_id=3,1,0)) as typearea3,
sum(IF(person.house_regist_type_id=4,1,0)) as typearea4
FROM
person
INNER JOIN village ON person.village_id = village.village_id
GROUP BY village.village_name
ไม่มีความคิดเห็น:
แสดงความคิดเห็น