Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!