Skip to content
Advertisement

SQL sum values in columns for each row

I have the following table:

column1 | column2 | column3
  1        3          4
  5        7          6

how do I sum the values of say, column 2 and 3, to return the sum?

The expected result is:

res
7
13

Advertisement

Answer

You can do maths within a select statement, so the following will work:

SELECT column2 + column3 AS res FROM table
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement