ผมใช้แบบนี้อยู่ครับ
select o.vstdate,o.icode,nd.name,count(o.icode) as counticode
,sum(o.qty) as sumqty,sum(o.sum_price) as sumsumprice
from opitemrece o
left outer join nondrugitems nd on nd.icode=o.icode
where o.vstdate between "2012-10-01" and "2012-10-20"
and o.icode in(select icode from nondrugitems where income="14") and o.icode<>"3904956"
group by o.icode
order by o.icode