select – Getting a The sum function requires 1 argument(s). error
SUM(column) is an aggregate function that sums the values across different rows. If you want to add values from a single row, you can do
SELECT m1 + m2 + m3 FROM.... You can also add the column values inside the rows, then sum it across rows like
SUM(m1 + m2 + m3). I would re-write you query as:
SELECT SUM(m1) sum1, SUM(m2) sum2, SUM(m3) sum3 FROM dbo.tablename WHERE area=000000 AND ownership=50 AND (code=113 OR code=114);
to get that specific answer as below.
area | ownership| code | m1 | m2 | m3
000000| 50 | 113+114| 42 | 40 | 44
once you want to see area and ownership this should have this columns on the sql and group by condition.
select area, ownership, sum(code), sum(m1), sum(m2), sum(m3) from dbo.tablename where area=000000 and ownership=50 and (code=113 or code=114) group by area, ownership;