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.
I think this is what you want.
UPDATE table_1
SET quarters = to_char(dateoftransfer, '"Q"Q YYYY');