SQL Server or MySQL:
select sum(MyColumn) as MyColumnSum from MyTable
If you need to summarize a column by grouping another column
select sum(MyColumn) as MyColumnSum, OtherColumn from MyTable Group By OtherColumn
Here is a way to individually add negative or positive numbers
select sum( case when MyColumn < 0 then MyColumn else 0 end ) as NegativeSum, sum( case when MyColumn > 0 then MyColumn else 0 end ) as PositiveSum from MyTable
Link
Brian webster
source share