Results 1 to 4 of 4
  1. #1
    krutoigoga is offline Novice
    Windows Vista Access 2007
    Join Date
    Apr 2010
    Posts
    20

    Count date entries from seperate tables/queries

    Hi all,
    I'm trying to create a report (chart) which would compare the # of entries from two separate tables or queries. My knowledge of access is limited, however I have tried a few things and was not successful.
    In this database (attached) I have two tables, each tracking a number of entries per day. The chart would show # of entries per month in both tables.
    I tried a union query - which did not work.
    Also tried to create a query with both fields from separate tables and it did not work.


    Any ideas?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    By chart do you mean a graph? Or tabular output with months as column headings? You want separate summary values for each table?

    First, UNION query:
    SELECT ID, drv_dates, "DRV" As Category FROM DRV_F
    UNION SELECT ID, GC_dates, "GC" FROM gc;

    Second, CROSSTAB query:
    TRANSFORM Count([ID]) AS CountOfID
    SELECT [Category]
    FROM UnionTables
    GROUP BY [Category]
    PIVOT Format([drv_dates],"mmm");

    All-in-one nested:
    TRANSFORM Count([ID]) AS CountOfID
    SELECT [Category]
    FROM (SELECT ID, drv_dates, "DRV" As Category FROM DRV_F
    UNION SELECT ID, GC_dates, "GC" FROM gc) As UnionQuery
    GROUP BY [Category]
    PIVOT Format([drv_dates],"mmm");
    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
    krutoigoga is offline Novice
    Windows Vista Access 2007
    Join Date
    Apr 2010
    Posts
    20
    Quote Originally Posted by June7 View Post
    By chart do you mean a graph? Or tabular output with months as column headings? You want separate summary values for each table?

    First, UNION query:
    SELECT ID, drv_dates, "DRV" As Category FROM DRV_F
    UNION SELECT ID, GC_dates, "GC" FROM gc;

    Second, CROSSTAB query:
    TRANSFORM Count([ID]) AS CountOfID
    SELECT [Category]
    FROM UnionTables
    GROUP BY [Category]
    PIVOT Format([drv_dates],"mmm");

    All-in-one nested:
    TRANSFORM Count([ID]) AS CountOfID
    SELECT [Category]
    FROM (SELECT ID, drv_dates, "DRV" As Category FROM DRV_F
    UNION SELECT ID, GC_dates, "GC" FROM gc) As UnionQuery
    GROUP BY [Category]
    PIVOT Format([drv_dates],"mmm");

    Thanks June7 - This worked, however the dates are not in sequential order..it is sorting by ascending the month name and ignoring the year.. please see attached if you need to see the cha .... i mean graph . I did not quiet understand your instructions - but its showing me what Im looking for. Thank you.

  4. #4
    krutoigoga is offline Novice
    Windows Vista Access 2007
    Join Date
    Apr 2010
    Posts
    20
    GROUP BY Format([drv_dates],"mmm/yyyy") fixed the date issue.
    Thanks June 7!

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

Similar Threads

  1. Queries, using record entries only once?
    By no1beyondfan in forum Queries
    Replies: 11
    Last Post: 04-20-2011, 08:57 AM
  2. select and insert using two seperate tables
    By benjammin in forum Queries
    Replies: 2
    Last Post: 02-20-2011, 04:52 PM
  3. Count Restricted by Date
    By cgjames in forum Queries
    Replies: 3
    Last Post: 01-19-2011, 04:41 PM
  4. Query to group and count field entries
    By newtoAccess in forum Queries
    Replies: 4
    Last Post: 11-29-2010, 09:19 AM
  5. Replies: 3
    Last Post: 05-21-2010, 03:57 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