ลองเอาสั่ง sql ไปประยุกต์ดูครับ
select a.hn,concat(pname,p.fname,' ',p.lname) as namept,a.order_date
,b.lab_items_code,c.lab_items_name
,count(a.hn) as amount,d.name as doctor
from lab_head a
left join lab_order b on b.lab_order_number=a.lab_order_number
left join lab_items c on c.lab_items_code=b.lab_items_code
left join doctor d on d.code=a.doctor_code
left join patient p on p.hn=a.hn
where a.order_date between '2008-1-1' and '2008-1-31'
group by a.hn,a.order_date,b.lab_items_code,a.doctor_code
having amount>1
order by a.hn,a.order_date,b.lab_items_code,a.doctor_code
น่าจะพอใช้ได้