ที่มา ระบบบันทึกข้อมูลภาวะโภชนาการ บัญชี 2/3
ข้อมูล A จำนวนเด็กส่วนสูงระดับดีและรูปร่างสมส่วน
select count(distinct person_id) from person where person_id in
(
select distinct p1.person_id
from person p1,person_wbc p2,person_wbc_nutrition p3
where p1.person_id = p2.person_id
and p2.person_wbc_id = p3.person_wbc_id
and p3.bmi_level = 3
and p3.height_level >= 3
and p1.in_region = 'Y'
and p1.birthdate between 'yyyy-mm-dd1' and 'yyyy-mm-dd2'
union
select distinct p1.person_id
from person p1,person_epi p2,person_epi_nutrition p3
where p1.person_id = p2.person_id
and p2.person_epi_id = p3.person_epi_id
and p3.bmi_level = 3
and p3.height_level >= 3
and p1.in_region = 'Y'
and p1.birthdate between 'yyyy-mm-dd1' and 'yyyy-mm-dd2'
)
ข้อมูล B จำนวนเด็กที่ชั่งน้ำหนักและวัดส่วนสูงทั้งหมด
select count(distinct person_id) from person where person_id in
(
select distinct p1.person_id
from person p1,person_wbc p2,person_wbc_nutrition p3
where p1.person_id = p2.person_id
and p2.person_wbc_id = p3.person_wbc_id
and p1.in_region = 'Y'
and p1.birthdate between 'yyyy-mm-dd1' and 'yyyy-mm-dd2'
union
select distinct p1.person_id
from person p1,person_epi p2,person_epi_nutrition p3
where p1.person_id = p2.person_id
and p2.person_epi_id = p3.person_epi_id
and p1.in_region = 'Y'
and p1.birthdate between 'yyyy-mm-dd1' and 'yyyy-mm-dd2'
)