I’m trying to sum some columns by id. But I’m retrieving 1 raw.
For Example
x
Id | C1| C2|
---------------------------------
1 | 2 | 1 |
2 | 5 | 4 |
3 | 3 | 1 |
4 | 5 | 2 |
Result that ı trying to get:
Id |Total
---------------------------------
1 | 3 |
2 | 9 |
3 | 4 |
4 | 7 |
How I can do this?
Advertisement
Answer
You just need addition operation +
as follows:
select id, c1+c2 as total
from your_table