Results 1 to 2 of 2

Thread: Count Sales Reps By Customers

  1. #1
    Join Date
    Dec 2009
    Posts
    79

    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?

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,922
    SELECT rep.rep_code, count(*)
    from Rep_Table rep
    group by rep.rep_code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •