I am quite new to the postgresql.
what is the best way to achieve this?
SELECT get_columns()
FROM table_name;
get_columns()
will provide the column names for the query. I saw people advising to use EXECUTE statement but I couldn't got that working.
Lets say there is table Test with columns a,b,c and I want to run
SELECT a,b FROM Test;
SELECT a,c FROM Test;
with column names generated dynamically.