I can't make my query work the way I need to. I have a simple query which outputs the following data:
What I need is to SUM the total_reseller_sales for each month and not display the same month twice. I try the following but it throws an error
SELECT rs.resellerid, rs.sid, SUM(rs.total_reseller_sales), s.month, s.sid
FROM sales_report_resellers rs
INNER JOIN resellers r ON rs.resellerid = r.resellerid
INNER JOIN sales_report s ON rs.sid = s.sid
WHERE (rs.sid > '294' AND rs.sid < '306') AND r.insidesales = 0
AND r.resellerid IN (7, 18, 22)
GROUP BY month
The error I get is that each element in SELECT is invalid because it is not contained in either an aggregate function or the GROUP BY clause.
If I include them i nthe GROUP BY, then I get the same results.
Any help would be appreciated.
