select o.hn,o.an,concat(pname,fname,' ',lname) as ptname,o.vstdate,d.name as drug,n.name as nondrug,qty,o.sum_price
from opitemrece o
left outer join vn_stat v on v.vn = o.vn
left outer join an_stat a on a.an = o.an
left outer join patient p on p.hn = o.hn
left outer join drugitems d on d.icode = o.icode
left outer join nondrugitems n on n.icode = o.icode
where o.vstdate between '2008-01-01' and '2008-01-31' and vsttime between '08%' and '16%'
and (v.pdx is null or v.pdx = '') and (a.pdx is null or a.pdx = '')
order by o.vstdate,o.hn