Add 'alias' columns in a row with Postgresql

0
nombre           nit    colum_alias1    colum_alias2    total_alias
--------------------------------------------------------------------    
nombre1           1      1,500            3,000           ? 
nombre2           2      2,000            4,000           ? 
--------------------------------------------------------------------    
total_columns_alias       ?                 ?             ? 

I keep thinking about this query, I would like to help me decipher the code to add the previous query of the alias columns and generate another query and get the totals by columns and by rows. I tried it with CUBE AND ROLLUP AND CROSSTAB. thanks

    
asked by Jsierra2017 05.04.2018 в 23:21
source

1 answer

1

I enclose the SQL Fiddle, this is more complex to say in SQL, it would be appropriate to write a PL / SQL package to add more flexibility to the program.

link

    
answered by 06.04.2018 в 00:07