BMS-HOSxP Community
HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: Apiruk_Jbhos ที่ พฤษภาคม 06, 2009, 10:18:11 AM
-
select hn,concat(fname," ",lname) as ptname,
count(concat(fname,lname)) as name_count
from patient
group by fname,lname
having count(concat(fname,lname))>1
order by name_count desc
อยากให้พี่ ๆ ช่วย แก้ให้หน่อยครับ
ตาม Code เก่ามัน group ไว้ ทำให้ HN ของแต่ละคนไม่ออก
อยากให้ออก HN มาด้วยครับ เพราะจะต้องเอา HN ไปทำการค้นหาครับ
ลองแก้แล้วยังไม่ออก HN ของทุกคนครับ
ขอบคุณครับ
-
ลองดูอันนี้ครับ
http://hosxp.net/index.php?option=com_smf&Itemid=28&topic=7076.msg36782#msg36782
select p.cid, p.hn,concat(p.fname," ",p.lname) as ptname,
p.birthday, p.fathername, p.mathername
from patient p, patient p2
where p.fname = p2.fname
and p.lname = p2.lname
and p.hn <> p2.hn
group by p.hn
order by ptname ,p.hn desc