select o.objName, a.attrDescription, count(*) itemCount
from tbl_PRD_SKus s
inner join tbl_ORG_Attributes a
on a.attrId = s.bgtCatId
inner join tbl_PRD_Skus bs
on bs.sku = s.sku
and bs.mfrId = s.ownerId
and bs.inactive = '0'
and bs.crmActive = 'Y'
inner join tbl_CRM_InteractionSaleDetails isd
on isd.saleSubjectId = bs.skuId
and isd.saleSubjectType = 'SKU'
inner join tbl_CRM_interactions i
on i.interactionId = isd.interactionId
inner join tbl_BCRM_ObjectiveTrgLink t
on t.targetType = i.partnerType
and t.targetId = i.partnerId
inner join tbl_BCRM_Objectives o
on o.objectiveId = t.objectiveId
and o.objOwnerId = s.ownerId
and o.objOwnerType = s.fsl_tablecode
where s.ownerId = 122
and bs.ownerId = 14
group by o.objName, a.attrDescription
order by objName, itemCount desc, attrDescription