with data as ( select r.chainSequence, r.description, r.termStart, r.termEnd, r.startDate, r.endDate, r.requestId, r.status, r.comments from tbl_TPM_Contracts c with (nolock) inner join tbl_TPM_Requests r with (nolock) on r.contractId = c.contractId and r.ownerId = c.ownerId and r.ownerType = c.ownerType where c.ownerId = and c.ownerType = and c.contractId = ) select * from data order by chainSequence desc for JSON PATH, INCLUDE_NULL_VALUES