SELECT * FROM visit
LEFT JOIN visitdiag on visit.pcucodeperson=visitdiag.pcucode AND visit.visitno=visitdiag.visitno
WHERE visitdiag.diagcode IS NULL
AND visit.visitdate BETWEEN '2014-10-01' AND '2015-09-30';
