Results 1 to 8 of 8
  1. #1
    TAM is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    22

    How do I sum fields in a query with different date criteria from other table?


    Table 1: contains sales summed by salesrep by week_date for 5 years + current
    Table 2: contains sales rep, start_date and end_date

    Query: Sum sales by rep where (start_date >= week_date and end_date <=week_date)

    Each rep has different start and end dates.

    Thanks!!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,522
    join the two tbls/qrys on RepID.

    I dont see the need to limit the sales data by date,...why would a sales rep continue to sell if he doesnt work there anymore?
    Therefor their data will never go outside of the rep.end_date.

    So just sum all data by rep.

  3. #3
    TAM is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    22
    You're making judgments on the data when you don't know the reason I'm summing. The reps still work here. There are contests with different start and enddates by person because their incentives are unique. Is this the correct way to sum the data? In my sales column in the query I have the following criteria:

    'where[start_date]">=[ReportDate] And [end_date<=[ReportDate]

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Post the entire query SQL statement.

    What do you mean by 'in the sales column'? That criteria cannot be under the sales column.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    TAM is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    22
    Quote Originally Posted by June7 View Post
    Post the entire query SQL statement.

    What do you mean by 'in the sales column'? That criteria cannot be under the sales column.
    Good to know. Remember I am a beginner and I have not used the Query Wizard.

    The criteria would be placed in the Week_date Column?


    Query: Sum sales by rep where (start_date >= week_date and end_date <=week_date)

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    I would use:

    WHERE week_date BETWEEN start_date AND end_date

    Post the query full SQL statement for analysis.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    TAM is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    22
    I'm using the Query Wizard. Where would I find the SQL that is generated to post for analysis?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Switch the builder to SQL View.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 2
    Last Post: 04-02-2015, 12:45 PM
  2. Dcount for 2 criteria date fields
    By rmd62163 in forum Access
    Replies: 4
    Last Post: 04-22-2014, 09:51 AM
  3. Replies: 1
    Last Post: 02-19-2014, 05:49 PM
  4. Replies: 1
    Last Post: 10-29-2012, 08:15 AM
  5. Most Recent Date Criteria Across Two Fields
    By jaypoppin in forum Queries
    Replies: 5
    Last Post: 06-15-2012, 11:30 AM

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