Results 1 to 6 of 6
  1. #1
    maym14 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Sep 2017
    Posts
    3

    Count of two fields across two tables query

    Hi, I am a complete newbie when it comes to Access. I have, what should be, a fairly simple problem to solve.

    I am trying to write a query that will count the different number of race types across different track conditions for my horse racing database.

    So I have:
    Table 1 (field is called Race_Type)
    Table 2 (field is called Track_Condition)

    So I am looking for how many different occurrences of each race type there is across the different track conditions.

    I have tried to write an expression but I do not get the correct results.

    Should this be done through SQL? If so, how could I do this?



    Thank you for your assistance.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Really need more info. How are these tables related? Is there a Race_Type field in Table 2? Show example records.
    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.

  3. #3
    maym14 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Sep 2017
    Posts
    3
    No, there isn't a Race_Type field in table 2. I am not sure how to show you an example as my DB is too big?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Can use the Advanced edit window to build a table in your post. Can even copy/paste rows from Access table or query object.

    So how are these tables related?

    What do you mean by 'write an expression' - expression where?
    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
    maym14 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Sep 2017
    Posts
    3
    I have managed to re-create a small example in the attached.

    In the query, 'qrytest', you will see that I have managed to show the race type and the track condition. You can see in this very small sample size, that I have 4 "Open" type races (record 4-7). These are the only common race_types in the sample data.

    So I should be able to have another column that shows that race_type "Open" in track_condition of "Good" has 4 races in total (and the rest have 1 each).

    But I cannot work out how to do this?
    Attached Files Attached Files

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Create a new query from qrytest, make it a totals query (click on the E icon at the top), group by race type and track condition, then select any other field and use Count.

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

Similar Threads

  1. Replies: 4
    Last Post: 08-24-2016, 06:48 AM
  2. Help with mulitple count fields in one query
    By SDCragg in forum Queries
    Replies: 1
    Last Post: 03-01-2015, 02:01 AM
  3. Replies: 15
    Last Post: 12-06-2013, 01:41 PM
  4. 'Count' two fields in a Query
    By dr4ke in forum Queries
    Replies: 2
    Last Post: 01-18-2013, 10:00 AM
  5. Multiple count of query fields
    By BLD21 in forum Queries
    Replies: 2
    Last Post: 05-23-2011, 01:09 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