Описание
синтаксиса весьма красноречиво намекает о реализации
DO UPDATE SET ... WHERE condition
melkij=> create temp table foo (item int primary key, d date, price numeric);
CREATE TABLE
melkij=> insert into foo values (1, '2021-07-30', 100) on conflict (item) do update set price = excluded.price, d = excluded.d where excluded.d > foo.d;
INSERT 0 1
melkij=> table foo;
item | d | price
------+------------+-------
1 | 2021-07-30 | 100
(1 строка)
melkij=> insert into foo values (1, '2021-08-01', 110) on conflict (item) do update set price = excluded.price, d = excluded.d where excluded.d > foo.d;
INSERT 0 1
melkij=> table foo;
item | d | price
------+------------+-------
1 | 2021-08-01 | 110
(1 строка)
melkij=> insert into foo values (1, '2021-07-20', 80) on conflict (item) do update set price = excluded.price, d = excluded.d where excluded.d > foo.d;
INSERT 0 0
melkij=> table foo;
item | d | price
------+------------+-------
1 | 2021-08-01 | 110
(1 строка)