select v.hcode,v.hn,v.vstdate,c.number,p.cid,concat(p.pname,p.fname," ",p.lname) as ptname,v.age_y as age,p.birthday,s.name,
v.pdx,v.dx0,v.dx1,v.dx2,v.dx3,v.dx4,v.dx5,lh.order_date,lb.lab_items_name_ref,lb.lab_order_result as hba1c
from vn_stat v
left outer join lab_head lh on lh.vn=v.vn
left outer join opdscreen o on o.vn=v.vn
left outer join patient p on p.hn=v.hn
left outer join sex s on s.code= p.marrystatus
left outer join lab_order lb on lb.lab_order_number=lh.lab_order_number
left outer join clinicmember c on c.hn=v.hn
where v.vstdate between '2009-02-01' and '2009-10-31'
and c.clinic =(select sys_value from sys_var where sys_name='dm_clinic_code')
and lb.lab_items_code in ("185","160","xxx")
order by v.vstdate