DB2, SQL query to SUM 2 columns -


i need add columns in row. table data

id    col1     col2 1     10        20 2     11        20 3     12        20 

result expected

id    sum  1     30   2     31   3     32   

i tried sum(col1 + col2), gives sum of columns together.

sum() aggregating function (one give single result group of rows), not algebraic one: want addition (the mathematical sum) of 2 columns:

select id, col1 + col2 sum mytable 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -