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

185
Views
Insert, update or alter column in postgres when working with to_char

What i have;

3 tables in postgres 9.4. Table 1 is the main table tables 2 and 3 contain some additional data (an update multiplier) which is quarterly (eg. Q1 2017 formatted as varchar). Table 1 has a date of transaction in date format along with a price paid column. I've added a column called 'quarters' to populate with new data which will be stored as varchar.

What i want to do;

Generate a quartely column in table 1, which i can do using

SELECT to_char(dateoftransfer, '"Q"Q YYYY') as quarters
FROM  table_1;

If i then try;

UPDATE table_1 (quarters)
SELECT to_char(dateoftransfer, '"Q"Q YYYY') as quarters
FROM  table_1;

I get the following error

ERROR:  syntax error at or near "quarters"
LINE 1: (quarters)
     ^

Should i be using COPY or INSERT INTO in place? The reason i want the column in table 1 is so that i can generate an update price column in table 1 by using a WHERE statement to find the correct multiplier. Its an inflation adjustment calculation.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I think this is what you want.

UPDATE table_1 
SET quarters = to_char(dateoftransfer, '"Q"Q YYYY');
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!