Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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
coalesce(column2,0) + coalesce(column3,0)
You can do maths within a select statement, so the following will work:
SELECT column2 + column3 AS res FROM table
Add a comment
This works in postgresql.
select sum(col2+col3) from ( select col1, col2,col3,row_number() over() as rows from column_sum ) as foo group by rows order by rows;
col2+col3
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
coalesce(column2,0) + coalesce(column3,0)