select lnk.companyId from tbl_SEC_Groups g with (nolock) inner join tbl_SEC_CoGrpLink lnk on g.groupId = lnk.groupId where g.ownerId = 99 and g.fsl_tablecode = 'MSC' and lnk.coType = delete prt from tbl_PRT_IndustryPartnerLink prt where prt.ownerId = 99 and prt.fsl_tablecode = 'MSC' and partnerType = and partnerId not in ( )