SELECT visitdrug.drugcode,cdrug.drugname, 
SUM(visitdrug.unit) as unit,visitdrug.costprice as ราคาตต้นทุน่อหน่วย, 
visitdrug.realprice as ราคาขายต่อหน่วย, 
SUM(visitdrug.costprice*visitdrug.unit) as รวมราคาต้นทุน, 
SUM(visitdrug.realprice*visitdrug.unit) as รวมราคาต้นขาย 
from visit 
INNER JOIN visitdrug on visit.pcucode=visitdrug.pcucode and visit.visitno=visitdrug.visitno 
INNER JOIN visitdiag on visit.pcucode=visitdiag.pcucode and visit.visitno=visitdiag.visitno 
INNER JOIN cdrug on visitdrug.drugcode=cdrug.drugcode 
WHERE cdrug.antibio ='1' and visitdiag.diagcode like 'J0%' or 'J101' or 'J111' or 'J20%' or 'J21%' or 'B053' or 'H65%' or 'H66%' or 'H67%' or 'H72%' 
and visit.visitdate BETWEEN '2014-01-01' and '2014-09-30' 
GROUP BY visitdrug.drugcode;