Results 1 to 2 of 2
  1. #1
    sujitshukla is offline Novice
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    4

    Problem with Join

    Hi,

    I am having 2 tables, Both are joined b EmployeeID.
    One table has data from CMS in which agent name is repeated more than once based on calls handled for different skills, so for one agent it is possible to have 5-6 entries for 1 day. the second table has number of sales done by each agent and it will have total sales for each agent so only 1 entry per day per agent.



    I am trying to create a query so that it will give me total calls and total sales done by an agent.but i am getting incorrect result.
    Attaching an example file.

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Assume the EmployeeID which you use for join is agent's ID.( if not, you should not join on this field).

    In this posting, assume that for every call in callTable there is a totalsales in agent table, and vice versa.

    Following query will give the totals by date:
    Query: totalsByDate
    select b.EmployeeID, [Date],b.totalSales, count(a.employeeID) as totalCall from callTable as a inner join agentTable as b on a.employeeID=b.employeeID group by b.employeeID,b.totalsales,[Date]

    If you want grant total, use this one( this query use totalsByDate as data source):
    select EmployeeID, sum(totalSales) as GrandTotalSales, sum(totalCall) as grandTotalCall from totalsByDate group by b.employeeID

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Many to many self-join problem
    By dbdbdo in forum Database Design
    Replies: 1
    Last Post: 07-18-2010, 09:31 AM
  2. Problem with Left Join & VB6
    By msrdjan1 in forum Queries
    Replies: 0
    Last Post: 03-30-2010, 01:48 AM
  3. SQL JOIN statement
    By seen in forum Access
    Replies: 10
    Last Post: 01-15-2010, 05:34 PM
  4. Problem with "join" duplicating records
    By Zukster in forum Queries
    Replies: 0
    Last Post: 08-25-2009, 09:00 AM
  5. Dynamic Query Outer Join Problem
    By mjack003 in forum Queries
    Replies: 0
    Last Post: 07-21-2006, 01:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums