I would like to get the sum of column1, the sum of column2 and the total amount. In Postgres, I can do it like this: (pay attention to the star)
SELECT *, a+b AS total_sum FROM ( SELECT SUM(column1) AS a, SUM(column2) AS b FROM table )
But in Oracle, I get a syntax error and should use this:
SELECT a,b, a+b AS total_sum FROM ( SELECT SUM(column1) AS a, SUM(column2) AS b FROM table )
I really have a lot of columns to return, so I don't want to write the column names in the main query again. Is there a simple solution?
I cannot use a + b in an internal query because it is not known there. I do not want to use SELECT SELECT SUM(column1) AS a, SUM(column2) AS b, SUM(column1)+SUM(column2) AS total_sum .
sql oracle
karel Jan 18 2018-12-18T00: 00Z
source share