Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

113
Vistas
Update 1 column from another table

How can I make an update? Here is the code, that's doesnt work. ( three local tables are workable, i can't make the last query using update )

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;
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I think you want this:

UPDATE client
    SET card_period[2][1] = b.newDate
    FROM dataSets d 
    WHERE client.id = d.id;

Note that client is not mentioned twice in the query.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda