BMS-HOSxP Community
HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: komanp ที่ กุมภาพันธ์ 18, 2009, 14:45:30 PM
-
คลินิคผู้สูงอายุต้องการคัดกรองคนที่มีอายุมากกว่า 60 ปีขึ้นไป
ได้คำสั่ง
select cid,hn,pname,fname,lname ,birthday ,death from patient
where birthday <= '1949-01-01'
ผมต้องการให้มันคัดกรองด้วยว่ามารักษาด้วยโรคอะไร
รักษาอะไรมากที่สุด
ต้องใช้คำสั่งเพิ่มเข้าไปอีกครับ
ไปอ่านเห็น
select count(distinct hn) as person_count,count(vn) as visit_count
from vn_stat
where vstdate between 'xxxx' and 'xxxx'
and age_y > 60
-
รักษาอะไรมากที่สุด
ต้องใช้คำสั่งเพิ่มเข้าไปอีกครับ
??? ??? ??? ???
เพิ่มเติมรายละเอียดหน่อยครับ
-
ลองดูแบบนี้ ;D
select v.hn ,count(v.vn) as visitcount ,
timestampdiff(year,p.birthday,now()) as age_y,
concat(p.pname,p.fname," ",p.lname)as ptname,
p.birthday,p.addrpart,p.moopart,a.full_name ,v.pttype ,p.cid
from vn_stat v
left outer join patient p on p.hn =v.hn
left outer join thaiaddress a on p.chwpart =a.chwpart and p.amppart = a. amppart and p.tmbpart=a.tmbpart
where v.vstdate between '2009-01-01' and '2009-01-05'
group by v.hn
having visitcount >= 2 and age_y >='60'
-
รักษาอะไรมากที่สุด
ต้องใช้คำสั่งเพิ่มเข้าไปอีกครับ
ไม่เอารักษาอะไรก็ได้ครับ
-
ขอบคุณมากเลยครับ
-
select v.hn ,count(v.vn) as visitcount ,
timestampdiff(year,p.birthday,now()) as age_y,
concat(p.pname,p.fname," ",p.lname)as ptname,
p.birthday,p.addrpart,p.moopart,a.full_name ,v.pttype ,p.cid
from vn_stat v
left outer join patient p on p.hn =v.hn
left outer join thaiaddress a on p.chwpart =a.chwpart and p.amppart = a. amppart and p.tmbpart=a.tmbpart
where v.vstdate between '2009-01-01' and '2009-01-05'
group by v.hn
having visitcount >= 2 and age_y >='60'
v.hn p.birthday v.vn
ไม่เข้าใจว่าทำไมต้องมี v. p. ข้างหน้าด้วยครับ
-
อืมม..คล้ายๆกับการตั้งชื่อ-นามสกุล หรือ ชื่อจริงชื่อเล่นแบบนี้ เพื่อให้การอ้างอิงถึงตารางที่ต้องการได้ถูกต้อง ;D ;D