ผมลองร่างๆ มาๆด้ประมาณนี้ครับ
select vn.vstdate as vdate,p.patient_hn as hn,concat(p.pname,p.fname,' ',p.lname) as person_name,concat(pt.addrpart," ?. ",pt.moopart," ",ad.full_name) as fullad,
vn.pdx,w1.service_note as wbc_waistline,w1.body_weight as wbc_bw ,w1.height as wbc_h,n.name as wbc_nutrition
,en.body_weight as epi_bw,en.height as epi_h,n1.name as epi_nutrition,
pw.vaccine_bcg_date as bcg,pw.vaccine_hbv1_date as hbv1,
pw.vaccine_hbv2_date as hbv2,pw.vaccine_hbv3_date as hbv3,
pw.vaccine_dtp1_date as dtp1,pw.vaccine_dtp2_date as dtp2,
pw.vaccine_dtp3_date as dtp3,pe.vaccine_dtp4_date as dtp4,
pe.vaccine_dtp5_date as dtp5,pw.vaccine_opv1_date as opv1,
pw.vaccine_opv2_date as opv2,pw.vaccine_opv3_date as opv3,
pe.vaccine_opv4_date as opv4,pe.vaccine_opv5_date as opv5,
pe.vaccine_je1_date as je1,pe.vaccine_je2_date as je2,
pe.vaccine_je3_date as je3,pw.vaccine_mmr_date as mmr
from vn_stat vn
left outer join person p on p.patient_hn=vn.hn
left outer join person_wbc pw on pw.person_id=p.person_id
left outer join person_epi pe on pe.person_id=p.person_id
left outer join person_wbc_service w1 on w1.vn=vn.vn
left outer join nutrition_level n on n.nutrition_level = w1.nutrition_level
left outer join person_epi_nutrition en on en.person_epi_id=pe.person_epi_id
left outer join nutrition_level n1 on n1.nutrition_level = en.nutrition_level
left outer join patient pt on pt.hn=p.patient_hn
left outer join thaiaddress ad on ad.chwpart=pt.chwpart and ad.amppart=pt.amppart and ad.tmbpart=pt.tmbpart
where vn.vstdate between "2011-09-21" and "2011-09-21" and (pw.vaccine_bcg_date=vn.vstdate or pw.vaccine_hbv1_date=vn.vstdate or
pw.vaccine_hbv2_date=vn.vstdate or pw.vaccine_hbv3_date=vn.vstdate or
pw.vaccine_dtp1_date=vn.vstdate or pw.vaccine_dtp2_date=vn.vstdate or
pw.vaccine_dtp3_date=vn.vstdate or pw.vaccine_opv1_date=vn.vstdate or
pw.vaccine_opv2_date=vn.vstdate or pw.vaccine_opv3_date=vn.vstdate or
pw.vaccine_mmr_date=vn.vstdate or pe.vaccine_dtp4_date=vn.vstdate or
pe.vaccine_opv4_date=vn.vstdate or pe.vaccine_je1_date=vn.vstdate or
pe.vaccine_je2_date=vn.vstdate or pe.vaccine_je3_date=vn.vstdate or
pe.vaccine_dtp5_date=vn.vstdate or pe.vaccine_opv5_date=vn.vstdate ) order by vn.vstdate