 |
สอบถามผู้รู้หน่อยครับบบบ...เรื่อง กรองรายชื่อผู้ป่วยคลินิกความดันโลหิตสูงที่ไม่มาภายใน 2 ปี |
|
 |
|
|
 |
 |
|
select vn.vn,pt.cid,pt.hn,concat(pt.pname,pt.fname," ",pt.lname) as fullname,vn.age_y,count(c.clinic) as cc,dc.screen_datetime
from depression_screen dc
left outer join vn_stat vn on vn.vn=dc.vn
left outer join clinicmember c on c.hn=vn.hn
left outer join patient pt on pt.hn=c.hn
where dc.screen_datetime between "2014-01-01" and "2015-12-31"
and c.clinic in (select sys_value from sys_var where sys_name = "ht_clinic_code")
group by c.hn ,pt.pname,pt.fname,pt.lname
having count(c.clinic)=1
------------------------------------------------------------------------------------
จากคำสั่งด้านบน คือ กรองรายชื่อผู้ป่วยคลินิกความดันโลหิตสูงที่ไม่มาภายใน 2 ปี
-ติดตรงที่ คำสั่ง ไม่มาภายใน2ปี ต้องใสคำสั่ง อะไร และ จุดไหนครับ (พอดี ไม่ค่อยมีความรู้เรื่อง นี้ มากหนัก ขอแนะนำหน่อยครับบ)
Tag : PHP, MySQL
|
|
 |
 |
 |
 |
Date :
2016-01-12 15:02:45 |
By :
baby137 |
View :
787 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code
NOT BETWEEN
Code (SQL)
select vn.vn,pt.cid,pt.hn,concat(pt.pname,pt.fname," ",pt.lname) as fullname,vn.age_y,count(c.clinic) as cc,dc.screen_datetime
from depression_screen dc
left outer join vn_stat vn on vn.vn=dc.vn
left outer join clinicmember c on c.hn=vn.hn
left outer join patient pt on pt.hn=c.hn
where dc.screen_datetime not between "2014-01-01" and "2015-12-31"
and c.clinic in (select sys_value from sys_var where sys_name = "ht_clinic_code")
group by c.hn ,pt.pname,pt.fname,pt.lname
having count(c.clinic)=1
---------------------------------------
|
 |
 |
 |
 |
Date :
2016-01-12 15:07:00 |
By :
ipstarone |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอดูรายละเอียดตารางหน่อยครับ
|
 |
 |
 |
 |
Date :
2016-01-12 15:38:56 |
By :
armdbz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (SQL)
select vn.vn,pt.cid,pt.hn,concat(pt.pname,pt.fname," ",pt.lname) as fullname,vn.age_y,count(c.clinic) as cc,dc.screen_datetime
from depression_screen dc
left outer join vn_stat vn on vn.vn=dc.vn
left outer join clinicmember c on c.hn=vn.hn
left outer join patient pt on pt.hn=c.hn
where DATE_FORMAT(dc.screen_datetime,'%Y-%m-%d') between "2014-01-01" and "2015-12-31"
and c.clinic in (select sys_value from sys_var where sys_name = "ht_clinic_code")
group by c.hn ,pt.pname,pt.fname,pt.lname
having count(c.clinic)=1
|
 |
 |
 |
 |
Date :
2016-01-12 15:51:51 |
By :
ipstarone |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|