If you're using aggregate functions you always have to add a
GROUP BY
clause to tell the SQL engine by which column value it should aggregate (group) the data. The
HAVING
clause may be used to filter the resulting rows but this is not required, if not needed. Your query should look something like:
SELECT Months
, SUM(Payment) AS Gross
FROM tblMonthlyReports
GROUP BY Months
WHERE Months IS NOT NULL
AND Payment IS NOT NULL
THis will result in several records each showing the sum of payments for the belonging month (one record for each month that occurs in tblMonthlyReports).
...and don't forget the
WHERE
clause, otherwise the aggreation may stop at the first NULL value which will lead into incorrect results!