BMS-HOSxP Community

HOSxP => MySQL => ข้อความที่เริ่มโดย: panus_t ที่ กุมภาพันธ์ 04, 2014, 18:24:45 PM

หัวข้อ: ต้องการหา ovst.hn ที่มารับบริการในช่วงเวลาที่กำหนด แต่ไม่มีใน person.patient_hn
เริ่มหัวข้อโดย: panus_t ที่ กุมภาพันธ์ 04, 2014, 18:24:45 PM
ต้องการหา ovst.hn  ที่มารับบริการในช่วงเวลาที่กำหนด แต่ไม่มีใน person.patient_hn
แก้ไขคำสั่งให้หน่อยครับ
select o.hn,p.patient_hn
from ovst o
left outer join person p on p.patient_hn<>o.hn
where o.vstdate between "2012-10-01" and "2012-10-01"
group by o.hn
หัวข้อ: Re: ต้องการหา ovst.hn ที่มารับบริการในช่วงเวลาที่กำหนด แต่ไม่มีใน person.patient_hn
เริ่มหัวข้อโดย: pop_hosxp ที่ กุมภาพันธ์ 04, 2014, 20:48:33 PM
โค๊ด: SQL
  1. SELECT o.hn,p.patient_hn
  2. FROM ovst o
  3. LEFT OUTER JOIN patient pa ON pa.hn=o.hn
  4. LEFT OUTER JOIN person p ON p.cid=pa.cid
  5. WHERE o.vstdate BETWEEN "2012-10-01" AND "2012-10-01"
  6. AND (p.patient_hn IS NULL OR p.patient_hn LIKE '')
  7. GROUP BY o.hn