ผู้เขียน หัวข้อ: อาจารย์แก้รายงานให้เรียงลำดับจากเวลามาลงทะเบียนที่ห้องบัตรให้หน่อยครับ  (อ่าน 2815 ครั้ง)

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

ออฟไลน์ chaiya_chaiyo

  • Newbie
  • *
  • กระทู้: 42
  • Respect: +1
    • ดูรายละเอียด
select concat(pt.addrpart," ","Á."," ",pt.moopart," ","µ."," ",t3.name) as adr,t1.name as chw,t2.name as amp,t3.name as tmb,v.hn as HN,p.cardno as CID,o.icd10 as ICD10,pt.informname as N1,pt.informaddr as N2,
concat(pt.pname,pt.fname," "," ",pt.lname) as fullname,s.name as sex ,pt.birthday,
v.vstdate,na.name as nationality,pt.hometel
from vn_stat v,ovstdiag o,visit_pttype vp,ptcardno p,patient pt
left outer join sex s on s.code=pt.sex
left outer join nationality na on na.nationality=pt.nationality
left outer join thaiaddress t1 on t1.chwpart=pt.chwpart and t1.codetype=1
left outer join thaiaddress t2 on t2.chwpart=pt.chwpart and t2.amppart=pt.amppart and t2.codetype=2
left outer join thaiaddress t3 on t3.addressid=concat(pt.chwpart,pt.amppart,pt.tmbpart)

where v.vn=o.vn and v.vn=vp.vn and v.hn = pt.hn and vp.pttype="52"
and o.icd10 in ("Z021","Z027") and p.hn=v.hn
and v.vstdate between "2008-02-11" and "2008-02-11"group by v.hn
Mr.Panu Thipmud
โรงพยาบาลไชยา
อำเภอไชยา ตำบลตลาด จังหวัดสุราษฏร์ธานี
โทร 077-431466 ต่อ 107
โทร 087-8898-672
Hosxp Version 3.51.10.10
MySql Version 5.0

ออฟไลน์ thecoy

  • Hero Member
  • *****
  • กระทู้: 1,159
  • นักวิชาการคอมพิวเตอร์
  • Respect: 0
    • ดูรายละเอียด
เปลี่ยนจาก order by v.hn  เป็น order by v.vsttime  ดูครับ
โรงพยาบาลรัษฎา  ตรัง
CentOS 5.5  Ram  4  GB
HOSxP V.3.54.11.2 MySQL 5.1.30

ออฟไลน์ chaiya_chaiyo

  • Newbie
  • *
  • กระทู้: 42
  • Respect: +1
    • ดูรายละเอียด
ยังไม่ได้ครับ
Mr.Panu Thipmud
โรงพยาบาลไชยา
อำเภอไชยา ตำบลตลาด จังหวัดสุราษฏร์ธานี
โทร 077-431466 ต่อ 107
โทร 087-8898-672
Hosxp Version 3.51.10.10
MySql Version 5.0

ออฟไลน์ thecoy

  • Hero Member
  • *****
  • กระทู้: 1,159
  • นักวิชาการคอมพิวเตอร์
  • Respect: 0
    • ดูรายละเอียด
select concat(pt.addrpart," ","Á."," ",pt.moopart," ","µ."," ",t3.name) as adr,t1.name as chw,t2.name as amp,t3.name as tmb,v.hn as HN,p.cardno as CID,o.icd10 as ICD10,pt.informname as N1,pt.informaddr as N2,
concat(pt.pname,pt.fname," "," ",pt.lname) as fullname,s.name as sex ,pt.birthday,
v.vstdate,na.name as nationality,pt.hometel,o.vsttime
from vn_stat v,ovstdiag o,visit_pttype vp,ptcardno p,patient pt
left outer join sex s on s.code=pt.sex
left outer join nationality na on na.nationality=pt.nationality
left outer join thaiaddress t1 on t1.chwpart=pt.chwpart and t1.codetype=1
left outer join thaiaddress t2 on t2.chwpart=pt.chwpart and t2.amppart=pt.amppart and t2.codetype=2
left outer join thaiaddress t3 on t3.addressid=concat(pt.chwpart,pt.amppart,pt.tmbpart)

where v.vn=o.vn and v.vn=vp.vn and v.hn = pt.hn and vp.pttype="52"
and o.icd10 in ("Z021","Z027") and p.hn=v.hn
and v.vstdate between "2008-02-11" and "2008-02-11"group by v.hn  order by o.vsttime
แก้ตามตัวอักษรสีแดงครับ 
« แก้ไขครั้งสุดท้าย: กุมภาพันธ์ 08, 2010, 10:12:06 AM โดย thecoy »
โรงพยาบาลรัษฎา  ตรัง
CentOS 5.5  Ram  4  GB
HOSxP V.3.54.11.2 MySQL 5.1.30