select m.mfr_id, m.mfr_name, count(*) tpfRecords
from tbl_MFR_TPF_Detail tpf with (nolock)
inner join tblManufacturers m with (nolock)
on m.mfr_id = tpf.mfr_id
where not exists ( select * from sysobjects o where o.xtype = 'U' and o.name = 'tbl_MFR_TPF_Detail_MFR' + convert( varchar, m.mfr_id ))
and exists( select * from tbl_MFR_TPF_Detail tpf2 with (nolock) where tpf2.mfr_id = tpf.mfr_id )
group by m.mfr_id, m.mfr_name
order by tpfRecords desc, m.mfr_name