select i.an,i.hn,p.pname,p.fname,p.lname,i.regdate,i.regtime,i.dchdate,i.dchtime
,i.dchstts,i.dchtype,i.rfrolct,a.admdate,a.admit_hour
from ipt i
left join patient p on p.hn=i.hn
left join an_stat a on i.an=a.an
where i.dchtype=04
and a.admit_hour<24
*****
ประมาณนี้รึป่าว