select ct.assignedContractNbr, count( distinct cc.claimContractId ) claims from tbl_TPM_Contracts ct inner join tbl_TPM_Requests r on r.contractId = ct.contractId inner join tbl_TPM_ClaimContracts cc on cc.requestId = r.requestId and cc.reconciled = 'Y' inner join tbl_TPM_Claims c on c.claimId = cc.claimId where ct.ownerId = 54 and ct.ownerType = 'MFR' -- and ct.partnerType = 'CDR' and coalesce( cc.lastDate, coalesce( c.claimPeriodEnd, c.claimDate )) >= '11/01/2017' group by ct.assignedContractNbr order by claims desc select listenerId from tbl_SYS_EventListeners where ownerId = 54 and ownerType = 'MFR' and eventName = 'updateContractedSales' and listenerPath = '/mstrcfmod/TPM/workflow/listeners/updateContractedSalesListener.cfm' and eventSubjectType = 'TCT' insert into tbl_SYS_EventListeners ( ownerId, ownerType, eventName, eventSubjectType, listenerPath, useTransaction ) values( 54, 'MFR', 'updateContractedSales', 'TCT', '/mstrcfmod/TPM/workflow/listeners/updateContractedSalesListener.cfm', 'N' ) select ct.contractId from tbl_TPM_Contracts ct where ct.ownerId = 54 and ct.ownerType = 'MFR' and ct.assignedContractNbr =

#htmleditformat( _assignedContractNbr )# Queued