เป็นเบาหวานอย่างเดียว
select c.hn,concat(p.pname,p.fname," ",p.lname) as patient_name ,count(c.clinic) as cc
from clinicmember c,patient p
where c.hn = p.hn and c.clinic in (select sys_value from sys_var where sys_name = "dm_clinic_code")
group by c.hn ,p.pname,p.fname,p.lname
having count(c.clinic)=1
เป็นความดันอย่างเดียว
select c.hn,concat(p.pname,p.fname," ",p.lname) as patient_name ,count(c.clinic) as cc
from clinicmember c,patient p
where c.hn = p.hn and c.clinic in (select sys_value from sys_var where sys_name = "ht_clinic_code")
group by c.hn ,p.pname,p.fname,p.lname
having count(c.clinic)=1
เป็นเบาหวานและความดัน
select c.hn,concat(p.pname,p.fname," ",p.lname) as patient_name ,count(c.clinic) as cc
from clinicmember c,patient p
where c.hn = p.hn and (c.clinic in (select sys_value from sys_var where sys_name = "ht_clinic_code")
or c.clinic in (select sys_value from sys_var where sys_name = "dm_clinic_code") )
group by c.hn ,p.pname,p.fname,p.lname
having count(c.clinic)>1