Count Sales Reps By Customers
I have two tables, one for customers and one for our internal sales reps.
Each sales rep is assigned to a particular customer and I need to get a count, and listing, by sales rep, on who is assigned to what.
My customer table is:
Cust_Code
Cust_Name
My sales rep table has:
Cust_Code
Rep_Code
Rep_Name
My output would be like:
John Smith 10
Jane Smith 5
Joe Jones 11
etc.
I have
Code:
SELECT count(rep.rep_code), cust.cust_name
from Rep_Table rep, Customer_Table cust
group by cust_cust_name
But I get the exact same number for each sales rep, which I know is not correct.
What am I doing wrong?