select fp.mktCategoryId, f.filterLabel, f.sortRank, fp.mktSubCategoryId, oa.attrDescription, oa.sortRank, tpf.productItemCode sku, coalesce( s.skuDesc, 'Unknown' ) skuDesc, sum( forecast_qty ) forecast_qty, sum( forecast_amt ) forecast_amt from tbl_MFR_TPF_Detail tpf left join tbl_MFR_FocusProducts fp on fp.mktCategoryId = tpf.mktCategoryId and fp.mktSubCategoryId = tpf.mktSubCategoryId and fp.ownerId = tpf.mfr_id and fp.ownerType = left outer join tbl_CMM_Filters f on f.filterId = fp.mktCategoryId and f.ownerId = fp.ownerId and f.fsl_tablecode = fp.ownerType left outer join tbl_ORG_Attributes oa on oa.attrId = fp.mktSubCategoryId and oa.ownerId = fp.ownerId and oa.fsl_tablecode = fp.ownerType left outer join tbl_PRD_Skus s on s.skuId = tpf.skuId and s.ownerId = tpf.mfr_id and s.fsl_tablecode = where mfr_id = and tpartnerType = 'CDR' and ( or ( tpf.forecast_year = and tpf.forecast_month = ) ) and tpf.forecast_status = 'A' and tpf.tpartnerId = and tpf.mktCategoryId = and tpf.mktSubCategoryId = group by fp.mktCategoryId, f.filterLabel, f.sortRank, fp.mktSubCategoryId, oa.attrDescription, oa.sortRank , tpf.productItemCode, s.skuDesc having ( sum( forecast_qty ) <> 0 or sum( forecast_amt ) <> 0 ) and oa.attrDescription is null order by coalesce( f.sortRank, 100000 ), f.filterLabel, oa.sortRank, oa.attrDescription , s.sku