select i.hn,i.an,i.refer_out_number,i.regdate,i.regtime,i.ward,ia.bedno ,
concat(p.pname,p.fname,' ',p.lname) as ptname
, a.age_y,i.pttype ,pty.name as pttype_name ,w.name as ward_name,
concat(il.g,'-',il.t,'-', il.p,'-',il.a,'-',il.l) as gpal ,
(to_days(i.regdate)-to_days(il.lmp)) div 7 as ga,pg.child_count,pg.anc_complete
,p.cid,concat(p.addrpart," บ้านเลขที่ ",p.moopart," ม. ",t1.name," อ. ",t2.name," จ. ",t3.name) as fulladdr
from ipt i left outer join iptadm ia on ia.an=i.an
left outer join patient p on p.hn=i.hn
left outer join thaiaddress t1 on t1.tmbpart=p.tmbpart
and t1.amppart=p.amppart and t1.chwpart=p.chwpart and t1.codetype = 3
left outer join thaiaddress t2 on t2.amppart=p.amppart and t2.chwpart=p.chwpart and t2.codetype = 2
left outer join thaiaddress t3 on t3.chwpart=p.chwpart and t3.codetype = 1
left outer join an_stat a on a.an=i.an
left outer join pttype pty on pty.pttype=i.pttype
left outer join ward w on w.ward = i.ward
left outer join ipt_pregnancy pg on pg.an = i.an
left outer join labor l on l.an = i.an
left outer join doctor d on d.code = l.labor_who
left outer join ipt_labour il on il.an = i.an
where i.ipt_type=4
and i.an in (select an from ipt_pregnancy where deliver_type = 0 )
and i.regdate between '2010-10-1' and '2010-11-14' order by i.regdate desc,i.regtime desc
จากคำสั่งนี้ถ้าเราต้องการทราบวันที่คลอดด้วยเราต้องใส่คำสั่งอะไรลงไปแล้วใส่ที่ไหนครับ