แบบนี้พอไหวมั๊ย
select o.vn,o.hn,p.pname,p.fname,p.lname
,p.addrpart,p.moopart,a.full_name as address
,count(op.icode) as amount,s.bps,s.bpd
from ovst o
left join patient p on p.hn=o.hn
left join thaiaddress a on a.addressid=concat(p.chwpart,p.amppart,p.tmbpart)
left join opitemrece op on o.vn=op.vn
left join drugitems d on op.icode=d.icode
left join opdscreen s on s.vn=o.vn
where o.vstdate=now()
and d.name is not null
and o.hn in (select hn from clinicmember where clinic=
(select sys_value from sys_var where sys_name='ht_clinic_code'))
group by o.vn
having amount>=5
order by o.hn