select
h.contract_id,
h.pens_product_id,
pppp.id as product_param_id,
pppp.param_pl_id,
pp.name,
pp.brief,
pppp.value_int,
pppp.value_decimal,
pppp.value_string,
pppp.value_date,
pppp.value_bool,
pppp.value_ref,
pppp.note
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 pp
on pp.id = pppp.param_pl_id
where h.contract_id = 13063250
and current_timestamp between
h.begin_date
and coalesce(h.end_date, 'infinity')
and pp.id = 4443;