SELECT
    r.id,
    r.amountPaid,
    r.payed,
    r.companyFk
FROM receipt r
    JOIN client c ON c.id = r.clientFk
    JOIN vn.clientRisk cr ON cr.clientFk = c.id
        AND cr.companyFk = r.companyFk
WHERE r.id = ?
