Загрузка данных


join ourpension.contract_product_history cph
    on cph.pens_product_id = pppp.pens_product_id
   and cph.contract_id = :contractId
   and current_timestamp between
       cph.begin_date
       and coalesce(cph.end_date, 'infinity')

left join ourpension.contract_params cp
    on cp.contract_id = :contractId

WHERE tpprc.contract_id IS NULL