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
Post a Comment