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


COALESCE(
    pl_multi_3."name",
    product_vesting.account_vesting_type
) AS account_vesting_type,





LEFT JOIN LATERAL (
    SELECT
        ms."name" AS account_vesting_type
    FROM ourpension.contract_product_history cph
    JOIN prod_line.pens_product_param_pl pppp
        ON pppp.pens_product_id = cph.pens_product_id
       AND pppp.param_pl_id = 4443
    JOIN prod_line.pens_product_param_pl_hb_param_pl_multiselect link
        ON link.pens_product_param_pl_id = pppp.id
    JOIN prod_line.hb_param_pl_multiselect ms
        ON ms.id = link.hb_param_pl_multiselect_id
    WHERE cph.contract_id = contracts.id
      AND CURRENT_TIMESTAMP BETWEEN
          cph.begin_date
          AND COALESCE(cph.end_date, 'infinity')
    LIMIT 1
) product_vesting ON true