| SQL |
select distinct pod.cdrRecordId, cc.contractNbr
from tbl_TPM_Claims c with (nolock)
inner join tbl_TPM_ClaimContracts cc with (nolock)
on cc.claimId = c.claimId
and cc.ownerId = c.ownerId
and cc.ownerType = c.ownertype
inner join tbl_TPM_ProofOfdelivery pod with (nolock)
on pod.claimId = cc.claimId
and pod.ownerId = cc.ownerId
and pod.ownertype = cc.ownerType
and pod.contractNbr = cc.contractNbr
inner join tbl_CDR_Distributors cdr with (nolock)
on cdr.cdr_recordId = pod.cdrRecordId
and cdr.ownerId = pod.ownerId
and cdr.fsl_tablecode = pod.ownertype
where c.claimId = ?
and c.ownerId = ?
and c.ownerType = ?
order by pod.cdrRecordId, cc.contractnbr |