ผู้เขียน หัวข้อ: ช่วยดูคำสั่งให้ทีครับ  (อ่าน 5823 ครั้ง)

0 สมาชิก และ 7 บุคคลทั่วไป กำลังดูหัวข้อนี้

ออฟไลน์ MR.KRAPONG<>

  • Sr. Member
  • ****
  • กระทู้: 333
  • Respect: 0
    • ดูรายละเอียด
ช่วยดูคำสั่งให้ทีครับ
« เมื่อ: พฤศจิกายน 29, 2010, 13:08:49 PM »
0
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

จากคำสั่งนี้ถ้าเราต้องการทราบวันที่คลอดด้วยเราต้องใส่คำสั่งอะไรลงไปแล้วใส่ที่ไหนครับ
(รักษาการผู้ดูแลระบบ)เจ้าหน้าที่โรงพยาบาลแม่แจ่ม
73 หมู่ 4 ต.ช่างเคิ่ง อ.แม่แจ่ม จ.เชียงใหม่
phone : 053-485099ต่อ133  หรือ 080-1301641
e-mail : nana-natee@hotmail.com,natee.krapong@gmail.com
------------------------------------------------------------------------
server
OS = centos 5.3   ram 4 G   SQL 5.1.39 percona
------------------------------------------------------------------------
ขึ้นระบบ วันที่ 1 มีนาคม 2551
ขึ้นระบบโดยทีมงานคุณวีระวัฒน์ ใจอินผล(พี่เอก)
------------------------------------------------------------------------
ตอนนี้กำลังศึกษาครับ ช่วยแนะแนวและแนะนำด้วยนะครับ

ออฟไลน์ เกื้อกูล ครับ..

  • Hero Member
  • *****
  • กระทู้: 12,611
  • Respect: +169
    • ดูรายละเอียด
    • โรงพยาบาลปากท่อ
Re: ช่วยดูคำสั่งให้ทีครับ
« ตอบกลับ #1 เมื่อ: พฤศจิกายน 29, 2010, 13:16:28 PM »
0
ดูคำสั่งมันจะยาวไปอ่ะเปล่าครับ..จะช้าเวลาประมวลผลจริง..

ก็แค่ดึง field labor_date จากตาราง  ipt_pregnancy มาแสดงผลน่ะครับ
« แก้ไขครั้งสุดท้าย: พฤศจิกายน 29, 2010, 13:22:29 PM โดย Kuakool.. »
Implement  HOSxP  Start 2548 ---> NOW!
Station : 130 Client   V.3 Version  3.67.1.XX
Server  : CENTOS  +MySQL maria 10.x.x

ออฟไลน์ เกื้อกูล ครับ..

  • Hero Member
  • *****
  • กระทู้: 12,611
  • Respect: +169
    • ดูรายละเอียด
    • โรงพยาบาลปากท่อ
Re: ช่วยดูคำสั่งให้ทีครับ
« ตอบกลับ #2 เมื่อ: พฤศจิกายน 29, 2010, 13:21:35 PM »
0
select i.hn,i.an,i.refer_out_number,i.regdate,i.regtime,i.ward,ia.bedno  ,pg.labor_date as labour,
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

จากคำสั่งนี้ถ้าเราต้องการทราบวันที่คลอดด้วยเราต้องใส่คำสั่งอะไรลงไปแล้วใส่ที่ไหนครับ
Implement  HOSxP  Start 2548 ---> NOW!
Station : 130 Client   V.3 Version  3.67.1.XX
Server  : CENTOS  +MySQL maria 10.x.x

ออฟไลน์ MR.KRAPONG<>

  • Sr. Member
  • ****
  • กระทู้: 333
  • Respect: 0
    • ดูรายละเอียด
Re: ช่วยดูคำสั่งให้ทีครับ
« ตอบกลับ #3 เมื่อ: พฤศจิกายน 29, 2010, 13:24:48 PM »
0
แล้วผมต้องใช้คำสั่งไหนครับถ้าต้องการ
เลขHN,เลข13หลัก,ชื่อ-สกุล,ที่อยู่,วันที่มารับบริการ,วันที่คลอด,อายุ
ขอด้วยนะครับ
(รักษาการผู้ดูแลระบบ)เจ้าหน้าที่โรงพยาบาลแม่แจ่ม
73 หมู่ 4 ต.ช่างเคิ่ง อ.แม่แจ่ม จ.เชียงใหม่
phone : 053-485099ต่อ133  หรือ 080-1301641
e-mail : nana-natee@hotmail.com,natee.krapong@gmail.com
------------------------------------------------------------------------
server
OS = centos 5.3   ram 4 G   SQL 5.1.39 percona
------------------------------------------------------------------------
ขึ้นระบบ วันที่ 1 มีนาคม 2551
ขึ้นระบบโดยทีมงานคุณวีระวัฒน์ ใจอินผล(พี่เอก)
------------------------------------------------------------------------
ตอนนี้กำลังศึกษาครับ ช่วยแนะแนวและแนะนำด้วยนะครับ

ออฟไลน์ Svl2Nuk3

  • Hero Member
  • *****
  • กระทู้: 793
  • Respect: 0
    • ดูรายละเอียด
Re: ช่วยดูคำสั่งให้ทีครับ
« ตอบกลับ #4 เมื่อ: พฤศจิกายน 29, 2010, 13:35:25 PM »
0
แล้วผมต้องใช้คำสั่งไหนครับถ้าต้องการ
เลขHN,เลข13หลัก,ชื่อ-สกุล,ที่อยู่,วันที่มารับบริการ,วันที่คลอด,อายุ
ขอด้วยนะครับ

ตามด้านล่างนี่เลยครับ

select i.hn,i.an,i.refer_out_number,i.regdate,i.regtime,i.ward,ia.bedno  ,pg.labor_date as labour,
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

จากคำสั่งนี้ถ้าเราต้องการทราบวันที่คลอดด้วยเราต้องใส่คำสั่งอะไรลงไปแล้วใส่ที่ไหนครับ
I'm nuke (นุ๊ก)
My Blog  : http://www.codenuke.net
อดีต นวก.คอมฯ รพช.พรหมพิราม => 1 พ.ค. 52 - 30 ก.ย. 54
ปัจจุบัน : Software Engineer บริษัทแห่งหนึ่ง

ออฟไลน์ MR.KRAPONG<>

  • Sr. Member
  • ****
  • กระทู้: 333
  • Respect: 0
    • ดูรายละเอียด
Re: ช่วยดูคำสั่งให้ทีครับ
« ตอบกลับ #5 เมื่อ: พฤศจิกายน 29, 2010, 13:36:43 PM »
0
select i.hn,i.an,i.refer_out_number,i.regdate,i.regtime,i.ward,ia.bedno  ,pg.labor_date as labour,
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

จากคำสั่งนี้ถ้าเราต้องการทราบวันที่คลอดด้วยเราต้องใส่คำสั่งอะไรลงไปแล้วใส่ที่ไหนครับ
ทำไมไม่มีวันที่ในตารางlabourขึ้นเลยครับ
« แก้ไขครั้งสุดท้าย: พฤศจิกายน 29, 2010, 13:41:03 PM โดย นายกระป๋อง »
(รักษาการผู้ดูแลระบบ)เจ้าหน้าที่โรงพยาบาลแม่แจ่ม
73 หมู่ 4 ต.ช่างเคิ่ง อ.แม่แจ่ม จ.เชียงใหม่
phone : 053-485099ต่อ133  หรือ 080-1301641
e-mail : nana-natee@hotmail.com,natee.krapong@gmail.com
------------------------------------------------------------------------
server
OS = centos 5.3   ram 4 G   SQL 5.1.39 percona
------------------------------------------------------------------------
ขึ้นระบบ วันที่ 1 มีนาคม 2551
ขึ้นระบบโดยทีมงานคุณวีระวัฒน์ ใจอินผล(พี่เอก)
------------------------------------------------------------------------
ตอนนี้กำลังศึกษาครับ ช่วยแนะแนวและแนะนำด้วยนะครับ

ออฟไลน์ เกื้อกูล ครับ..

  • Hero Member
  • *****
  • กระทู้: 12,611
  • Respect: +169
    • ดูรายละเอียด
    • โรงพยาบาลปากท่อ
Re: ช่วยดูคำสั่งให้ทีครับ
« ตอบกลับ #6 เมื่อ: พฤศจิกายน 29, 2010, 13:38:22 PM »
0
แบบนี้พอได้ไหมครับ.. :D
« แก้ไขครั้งสุดท้าย: พฤศจิกายน 29, 2010, 13:44:41 PM โดย Kuakool.. »
Implement  HOSxP  Start 2548 ---> NOW!
Station : 130 Client   V.3 Version  3.67.1.XX
Server  : CENTOS  +MySQL maria 10.x.x

ออฟไลน์ MR.KRAPONG<>

  • Sr. Member
  • ****
  • กระทู้: 333
  • Respect: 0
    • ดูรายละเอียด
Re: ช่วยดูคำสั่งให้ทีครับ
« ตอบกลับ #7 เมื่อ: พฤศจิกายน 29, 2010, 13:48:12 PM »
0
แบบนี้พอได้ไหมครับ.. :D

อีกทีนะครับ ข้างบน
(รักษาการผู้ดูแลระบบ)เจ้าหน้าที่โรงพยาบาลแม่แจ่ม
73 หมู่ 4 ต.ช่างเคิ่ง อ.แม่แจ่ม จ.เชียงใหม่
phone : 053-485099ต่อ133  หรือ 080-1301641
e-mail : nana-natee@hotmail.com,natee.krapong@gmail.com
------------------------------------------------------------------------
server
OS = centos 5.3   ram 4 G   SQL 5.1.39 percona
------------------------------------------------------------------------
ขึ้นระบบ วันที่ 1 มีนาคม 2551
ขึ้นระบบโดยทีมงานคุณวีระวัฒน์ ใจอินผล(พี่เอก)
------------------------------------------------------------------------
ตอนนี้กำลังศึกษาครับ ช่วยแนะแนวและแนะนำด้วยนะครับ

ออฟไลน์ เกื้อกูล ครับ..

  • Hero Member
  • *****
  • กระทู้: 12,611
  • Respect: +169
    • ดูรายละเอียด
    • โรงพยาบาลปากท่อ
Re: ช่วยดูคำสั่งให้ทีครับ
« ตอบกลับ #8 เมื่อ: พฤศจิกายน 29, 2010, 13:53:26 PM »
0
and i.an  in (select an from ipt_pregnancy where deliver_type = 0 )

ก็ deliver_type = 0  หมายถึง รอคลอดนะครับ

ถ้าอยากได้คนที่คลอด ก็ต้อง  deliver_type = 1
Implement  HOSxP  Start 2548 ---> NOW!
Station : 130 Client   V.3 Version  3.67.1.XX
Server  : CENTOS  +MySQL maria 10.x.x

ออฟไลน์ MR.KRAPONG<>

  • Sr. Member
  • ****
  • กระทู้: 333
  • Respect: 0
    • ดูรายละเอียด
Re: ช่วยดูคำสั่งให้ทีครับ
« ตอบกลับ #9 เมื่อ: พฤศจิกายน 29, 2010, 14:30:19 PM »
0
and i.an  in (select an from ipt_pregnancy where deliver_type = 0 )

ก็ deliver_type = 0  หมายถึง รอคลอดนะครับ

ถ้าอยากได้คนที่คลอด ก็ต้อง  deliver_type = 1


คุณครับ
(รักษาการผู้ดูแลระบบ)เจ้าหน้าที่โรงพยาบาลแม่แจ่ม
73 หมู่ 4 ต.ช่างเคิ่ง อ.แม่แจ่ม จ.เชียงใหม่
phone : 053-485099ต่อ133  หรือ 080-1301641
e-mail : nana-natee@hotmail.com,natee.krapong@gmail.com
------------------------------------------------------------------------
server
OS = centos 5.3   ram 4 G   SQL 5.1.39 percona
------------------------------------------------------------------------
ขึ้นระบบ วันที่ 1 มีนาคม 2551
ขึ้นระบบโดยทีมงานคุณวีระวัฒน์ ใจอินผล(พี่เอก)
------------------------------------------------------------------------
ตอนนี้กำลังศึกษาครับ ช่วยแนะแนวและแนะนำด้วยนะครับ