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


FROM prod_line.table_param_pl_redemption_coeff tpprc

join prod_line.pens_product_param_pl pppp
    on pppp.id = tpprc.pens_product_param_pl_id

left join prod_line.hb_stage hs
    on hs.id = tpprc.stage_id

join prod_line.param_pl pp
    on pp.id = pppp.param_pl_id

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