最終来院日が20121130以前、および一度も来院のない患者のSQL文
SELECT substring(ptnum from 1 for 6) ,name,lastymd FROM tbl_ptnum a,tbl_ptinf b LEFT OUTER JOIN tbl_srykarrk USING(ptid) WHERE (b.ptid NOT IN (SELECT ptid FROM tbl_srykarrk WHERE lastymd>='20121201')) AND a.ptid=b.ptid ORDER BY ptnum;