CREATE OR REPLACE VIEW fies.v_tp_fin_group_cost_link AS
 SELECT t1.tpfingroupid::character varying(36)::text || a1.tpcostitemid::character varying(36)::text AS tpfingroupcostlinkid,
    t1.tpfingroupid AS tpfingroup,
    a1.tpcostitemid AS tpcostitem
   FROM fies.t_tp_fin_group t1
     JOIN fies.t_tp_fin_type_link t2 ON t2.tpfintypelinkid = t1.tpfintypelink
     JOIN fies.t_tp_fin_type t3 ON t3.tpfintypeid = t2.tpfintype
     JOIN fies.t_tp_link t4 ON t4.tpfintype = t3.tpfintypeid
     JOIN fies.t_tp_fin t5 ON t5.tpfinid = t1.tpfin
     JOIN fies.t_tp_cost_item a1 ON a1.tpcost = t5.tpcost AND a1.tptype = t4.tptype;
