SELECT visitdrug.drugcode,cdrug.drugname,visitdrug.unit,
visitdrug.realprice , 
visitdrug.costprice,
(visitdrug.unit*visitdrug.costprice) as totalcost,
(visitdrug.unit*visitdrug.realprice) as totalprice,
(visitdrug.unit*visitdrug.realprice)-(visitdrug.unit*visitdrug.costprice) as profit
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;