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

188
Vistas
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 Respuestas
Responde la pregunta

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 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