จากคำสั่งนี้ผมจะรวม สิทธิ์ ให้เป็นเหมือนในตาราง pttype_spp จะต้องไปเพิ่มยังไงครับ
select lg.lab_items_group_name ,p.name,p.hipdata_code,count(o.lab_items_code) as cc
from lab_items_group lg
left outer join lab_items i on i.lab_items_group= lg.lab_items_group_code
left outer join lab_order o on o.lab_items_code = i.lab_items_code
left outer join lab_head lh on lh.lab_order_number=o.lab_order_number
left join vn_stat ov on ov.vn=lh.vn
left join pttype p on ov.pttype=p.pttype
where lh.order_date between "2007-10-01" and "2008-09-30" and length(lh.vn)=12
and o.lab_order_result is not null and o.lab_order_result<>''
group by p.name
order by lg.lab_items_group_name