select spl.opportunityId from tbl_SPL_Opportunities spl inner join tbl_SPL_Stages s on s.stageId = spl.stageId and s.ownerId = spl.ownerId and s.ownerType = spl.ownerType where s.statusCode in ( 'A', 'I' ) and spl.ownerId = 2 and spl.ownerType = 'BRO' and spl.mfrId = #_saralee# select spl.opportunityId from tbl_SPL_Opportunities spl inner join tbl_SPL_Stages s on s.stageId = spl.stageId and s.ownerId = spl.ownerId and s.ownerType = spl.ownerType where s.statusCode in ( 'A', 'I' ) and spl.ownerId = 2 and spl.ownerType = 'BRO' and spl.mfrId = #_saralee#