¿Cómo puedo hacer una actualización? Aquí está el código, eso no funciona. (Tres tablas locales son viables, no puedo hacer la última consulta usando la actualización)
WITH allowedIds AS ( SELECT client_id as id FROM cardHistory WHERE ( (now())::date -(date_set)::date )::int > 1095 ), thirtyPercents AS ( SELECT a.id, ( ( (card_period[2][1])::date - (card_period[1][1])::date)::double precision / 10 ) * 3 AS percent FROM client a, allowedIds b WHERE a.id = b.id ), dataSets AS ( select a.id, (a.card_period[2][1] + ( (b.percent)::int * interval '1 day' ) ) as newDate from client a, thirtyPercents b where a.id = b.id ) UPDATE client SET a.card_period[2][1] = b.newDate FROM dataSets b INNER JOIN client a ON a.id = b.id;Creo que quieres esto:
UPDATE client SET card_period[2][1] = b.newDate FROM dataSets d WHERE client.id = d.id; Tenga en cuenta que el client no se menciona dos veces en la consulta.