SQL: count question
Posted on 2011-03-01
We have 20 sales reps. I am creating a basic query that counts how many items sold this month per sales rep.
SELECT SR.SalesRep, COUNT(*)
FROM SalesReps SR LEFT OUTER JOIN Items I ON I.SalesRep = SR.SalesRepNo
GROUP BY SR.SalesRep
I want all 20 Sales reps to show up, even if they did not sell anything. If they didn't sell anything, I want to see a 0.
However, since ONLY 13 sales reps sold something thus far in March, I am only getting 13 items, not all 20.
How do I modify my query to show all 20 sales reps whether they sold something or not.