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


select
    h.contract_id,
    h.pens_product_id,
    pppp.id as product_param_id,
    pp2.brief,
    pppp.value_int,
    pppp.value_decimal,
    pppp.value_string,
    pppp.value_ref
from ourpension.contract_product_history h
join prod_line.pens_product_param_pl pppp
    on pppp.pens_product_id = h.pens_product_id
join prod_line.param_pl pp2
    on pp2.id = pppp.param_pl_id
where h.contract_id = 13548906
  and current_timestamp between
      h.begin_date
      and coalesce(h.end_date, 'infinity')
  and pp2.brief = 'СрокОжиданияПервогоВзносаКоличДней';