select opr.companyName, ct.assignedContractNbr, ct.contractName
from tbl_TPM_Contracts ct with (nolock)
inner join tbl_OPR_CLientOperators opr with (nolock)
on opr.operatorId = ct.partnerId
and opr.fsltablecode = ct.ownerType
and opr.ownerId = ct.ownerId
inner join tbl_TPM_Requests r with (nolock)
on r.contractId= ct.contractId
and r.ownerId = ct.ownerId
and r.ownerType = ct.ownerType
and r.chainSequence = ct.lastApprovedChainSequence
where r.ownerId = 1
and r.ownerType = 'MFR'
order by opr.companyName, ct.assignedContractNbr
select * from qmd_agreements
order by fileSize desc, companyName