Brasciole - 11 months ago 34

SQL Question

I'm struggling with calculating the SUM on a Query that has a SUM. Here's my query:

`SELECT rs.resellerid, r.company, r.insidesales, SUM(total_reseller_sales) as TotalResellerSalesYear FROM sales_report_resellers rs INNER JOIN resellers r ON rs.resellerid = r.resellerid WHERE (sid > '282' AND sid < '292') AND r.insidesales = 1 GROUP BY rs.resellerid, r.company, r.insidesales`

The query returns 5 records with each a dollar amount. I need to the SUM of all 5 records.

Answer

Remove `Group By`

and non aggregate columns from `Select`

list

```
SELECT SUM(total_reseller_sales) as Total
FROM sales_report_resellers rs
INNER JOIN resellers r
ON rs.resellerid = r.resellerid
WHERE (sid > '282' AND sid < '292')
AND r.insidesales = 1
```