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

405
Views
how to change row value Postgresql following above row?

I have a query result like this

id | code | data
1  | b001 | 12
1  | b001 | 13
1  | b001 | 15
2  | b002 | 20
2  | b002 | 15
2  | b002 | 10

i want to change the data value into 12 and 20 for every different id like this :

id | code | data
1  | b001 | 12
1  | b001 | 12
1  | b001 | 12
2  | b002 | 20
2  | b002 | 20
2  | b002 | 20
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You need to use first_value window function

Add this to your SELECT:

(first_value(data) OVER (PARTITION BY id)) as data
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!