select stageId from tbl_SPL_Stages with (nolock) where ownerId = and ownerType = and statusCode = 'A' select COUNT(*) as APlusOperatorCount from tbl_OPR_ClientOperators opr with (nolock) where opr.ownerId = and opr.fsltablecode = and opr.oprtype = '*' and opr.crmActive = 'Y' and opr.territoryId in ( ) and opr.territoryId > 0 select round( sum( caseAmt ), 0 ) as APlusOpportunityVolume from tbl_SPL_Opportunities with (nolock) where ownerId= and ownerType = and ( ( partnertype='OPR' and partnerId in ( select opr.operatorId from tbl_OPR_ClientOperators opr with (nolock) where opr.ownerId = and opr.fsltablecode = and opr.oprtype = '*' and opr.crmActive = 'Y' and opr.territoryId in ( ) and opr.territoryId > 0 ) ) or ( partnertype='CDR' and partnerId in ( select cdr.cdr_recordId from tbl_CDR_Distributors cdr with (nolock) where cdr.ownerId = and cdr.fsl_tablecode = and cdr.cdr_priority = '*' and cdr.crmActive = 'Y' and cdr.cdr_territoryid in ( ) and cdr.cdr_territoryid > 0 ) ) ) and stageId in ( ) select COUNT(*) as AUniquePurchasingCompanies from tbl_OPR_ClientOperators opr with (nolock) where opr.ownerId = and opr.fsltablecode = and opr.oprtype = 'A' and opr.crmActive = 'Y' and opr.territoryId in ( ) and opr.territoryId > 0 and exists ( select * from tbl_OPR_ProductStatus ps with (nolock) where ps.purchasingStatus = 'B' and ps.ownerId = opr.ownerId and ps.ownerType = ps.ownerType and ps.operatorId = opr.operatorId ) select sum( case when ps.volumeTime = 'W' then 52 when ps.volumeTime = 'M' then 12 else 1 end * volumeQty ) as AAnnualVolume from tbl_OPR_ClientOperators opr with (nolock) inner join tbl_OPR_ProductStatus ps with (nolock) on ps.ownerId = opr.ownerId and ps.ownerType = opr.fsltablecode and ps.operatorId = opr.operatorId and ps.purchasingStatus in ( 'B' ) and ps.volumeTime in ( 'W','M','Y' ) where opr.ownerId = and opr.fsltablecode = and opr.oprtype = 'A' and opr.crmActive = 'Y' and opr.territoryId in ( ) and opr.territoryId > 0