I've created table rep where I store strings which are repeated in a few of my queries, example: ('birthday_month', 'extract(month from my_table)') but there are a few much longer with CASE, and function which returns value for input key. Now I would like to concatenate sql select using records from this table.
select name, (select get_rep('birthday_month')) as timestep
group by timestep
extract(month from my_table) 12345
Just create a view with all the columns you want:
create view v_my_table select t.*, extract(month from date_of_birth) as birthday_month from my_table t;
You can add as many more columns as you like.
Then use the columns that you want in a query:
select birthday_month, count(*) from v_my_table group by birthda_month;