I am trying to create a dynamic column in a table whose column name will be today's date and values will be populated based on a mathematical operation of an existing column. For example table, t1 has column a,b,c and I want to add a column called '04-26-2021' whose value will be a+b+c values. Does anyone know how we can implement it in Postgresql? Thanks
Asked
Active
Viewed 318 times
0
-
see if this answer helps https://stackoverflow.com/questions/39779734/dynamically-generate-columns-in-postgresql or https://stackoverflow.com/questions/4104508/postgres-dynamic-column-headers-from-another-table – Ian Kenney Apr 27 '21 at 04:29
-
You are looking for a "view", an object that looks like a table, but is a query with a name. – Laurenz Albe Apr 27 '21 at 06:00
-
Why wouldn't you just call the column `today`? – Gordon Linoff Apr 27 '21 at 12:07
-
@IanKenney Thanks for the suggestion. But I am not storing date values in any column. I want to generate dynamically. – Nityanand wachche May 14 '21 at 06:22