insert into gp_front_v.data_oks (
  period_key,
  oks, oks_name, address, subject_code, subject_name, power,
  --is_comis, comis_date,
  readness_fact, oks_status_color,
  photo_status, video,
  photo_1, photo_2, photo_3,
  risk_code,
  --risk_name,
  date_start, date_end, 
  photo_sputnik, video_status, res_id, res_name, ri_id,
  --res_version_meta_id, ri_version_meta_id,
  photo_1_date, photo_2_date, photo_3_date,
  "update_ts$", oks_status, oks_status_name, video_list, photo_list,
  risk_flag, risk_description,
  problem_name, oks_reason_name,
  fed_code, sp_code, sp_name, qr_status, "insert_ts$"
) 
select '2024-03' as period,
       g.o_oks_code, o_oks_name, o_address, o_subject_code, o_subject_name,
       o_power, o_readness_fact,
       case
         when o_oks_status_name = 'Построено, Реконструировано' then 'Зеленый'
         when o_oks_status_name = 'Строится' then 'Желтый'
         when o_oks_status_name = 'Просрочено' then 'Красный'
       end as oks_status_color,
       case
         when o_photos_preview is not null and o_photos_preview = 'true' then true
         when o_photos_preview is null or o_photos_preview = 'false' then false
       end as photo_status,
       m.video,
       m.photo_1,
       m.photo_2,
       m.photo_3,
       o_risk,
       extract (year from o_start_construction_date) as date_start,
       extract (year from o_end_construction_date) as date_end,
       o_roskosmos_preview,
       case
         when m.video is not null then true
         when m.video is null then false
       end as video_status,
       o_id_event, o_event, o_id_event_value,
       photo_date_1, photo_date_2, photo_date_3,
       now()::timestamp as update_ts$, o_oks_status::int, o_oks_status_name,
       g.o_video,
       m.photo_list,
       case
         when o_risk is not null then true
         when o_risk is null then false
       end as risk_flag,
       o_risk_description, o_problem_name, o_oks_reason_name
       o_fed_code, o_gosprog, o_gosprog_name,
       case
         when o_qr is not null and o_qr = 1 then 1
         when o_qr is null or o_qr = 0 then 0
       end as o_qr,
       now()::timestamp as insert_ts$
  from fv_objects_grid_v g
  right join (
        select oks_code,
               max(case when row_num = 1 and media_type = 'photo' then link end) as photo_1,
               max(case when row_num = 2 and media_type = 'photo' then link end) as photo_2,
               max(case when row_num = 3 and media_type = 'photo' then link end) as photo_3,
               max(case when row_num = 4 and media_type = 'video ' then link end) as video,
               max(case when row_num = 1 and media_type = 'photo' then date_photo end) as photo_date_1,
               max(case when row_num = 2 and media_type = 'photo' then date_photo end) as photo_date_2,
               max(case when row_num = 3 and media_type = 'photo' then date_photo end) as photo_date_3,
               max (media_list) as photo_list
          from (
               select oks_code,
                      media_type,
                      date_photo,
                      link,
                      row_number() over (partition by oks_code) as row_num,
                      string_agg(link, ', ') filter(where media_type = 'photo') over (partition by oks_code) as media_list
                 from gp_v.oks_media_for_gosprog
                 ) as ranked_links
         group by oks_code--, media_list         
         ) m
    on g.o_oks_code = m.oks_code;
посмотри какое поле лишнее в insert