Я пытаюсь использовать ограничение для обновления строк в случае дубликатов, обнаруженных в postgres, но я получаю сообщение об ошибке "ОШИБКА: отсутствует запись предложения FROM для таблицы" test1 ""
INSERT INTO wfo_data_aggregation.test2
SELECT *
FROM wfo_data_aggregation.test1
ON CONFLICT ON CONSTRAINT test2_un
do update set inbound_handled_seconds = wfo_data_aggregation.test1.inbound_handled_seconds
AND contacts_handled_inbound = wfo_data_aggregation.test1.contacts_handled_inbound
AND outbound_handled_seconds = wfo_data_aggregation.test1.outbound_handled_seconds
AND contacts_handled_outbound = wfo_data_aggregation.test1.contacts_handled_outbound
WHERE NOT EXISTS (SELECT *
FROM wfo_data_aggregation.test2
WHERE start_time = wfo_data_aggregation.test1.start_time
AND end_time = wfo_data_aggregation.test1.end_time
AND site_name = wfo_data_aggregation.test1.site_name
AND skill_id = wfo_data_aggregation.test1.skill_id
and site_id = wfo_data_aggregation.test1.site_id
AND channel = wfo_data_aggregation.test1.channel
AND inbound_handled_seconds = wfo_data_aggregation.test1.inbound_handled_seconds
AND contacts_handled_inbound = wfo_data_aggregation.test1.contacts_handled_inbound
AND outbound_handled_seconds = wfo_data_aggregation.test1.outbound_handled_seconds
AND contacts_handled_outbound = wfo_data_aggregation.test1.contacts_handled_outbound
AND tenure = wfo_data_aggregation.test1.tenure )