Results 1 to 8 of 8
  1. #1
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368

    best way to accomplish this (aggregate tables)

    Hi everyone.

    Here's my current situation. I have tables consisting of customer information for this year's media campaigns. They all have the same fields. I need to aggregate these into one table. The trick is that the same customer may have been campaigned in multiple times and I need to capture the earliest campaign and omit the later campaign.

    For example:

    tblCampaignJan1
    CustID, EnrollmentID, CampaignDate
    1, 123, 1/1/2011

    tblCampaignFeb1
    CustID, EnrollmentID, CampaignDate


    1, 123, 2/1/2011

    My aggregate table will need to only contain the record from the earliest campaign date. My current ideas involve multiple queries. is it possible to do this in one shot?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Well, it was likely a normalization mistake to have a table for each campaign. My guess is that you first need to use a UNION query to pull all the data together, and then this type of thing to get the earliest record for each customer:

    http://www.baldyweb.com/LastValue.htm

    If the data is really that simple, a basic totals query will let you pull out one record for each customer with the Min() date (based on the UNION query).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    The table for each campaign is due to not using access to create the campaigns to begin with. each table is an excel sheet that was imported. I dont aggregate them together at the beginning because the totals for the campaign is over a million. the query to find the enrollments hit a table of 5mil+ joined with another table of 5mil+. The result of which balloons Access to over 2GB and kills the query.

    The method in your link was what I was considering, just wanted to see if there was a way to combine the union with the Min() and have it go in one shot. Thanks

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I'd probably still import the data into one table, though with that many records I'd use SQL Server for the data (there's a free version). That way you can use a stored procedure or pass through query and let the server do all the work.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    I have the full version of SQL Server through MSDNAA. It's not "company IT approved" for my purposes, so I cant use it. Hell, if I had it may way, all these reports would be sitting on VB projects to be run on the fly and on demand by whoever wants them.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I like being both developer and IT Manager. All my requests get approved.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    I'm still trying to get INSERT rights to a table so i can avoid a 5k record per upload limit through the web UI when I have campaigns of over 60k each. Got any openings? =P

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I'm pretty much a department of 1, so an opening would mean that I fired myself. Sorry, no openings!

    I sympathize with having to work around stupid restrictions though. I've had to do it in the past, and it's frustrating.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. more aggregate function questions
    By boutwater in forum Access
    Replies: 6
    Last Post: 09-29-2011, 02:53 PM
  2. Aggregate Query
    By DonL in forum Queries
    Replies: 1
    Last Post: 08-04-2011, 09:54 AM
  3. Help in aggregate query
    By somm in forum Queries
    Replies: 1
    Last Post: 02-15-2011, 10:18 AM
  4. Will access accomplish this?
    By Andy128 in forum Access
    Replies: 1
    Last Post: 07-10-2010, 01:47 PM
  5. Using an Aggregate in a query
    By jbh02 in forum Queries
    Replies: 0
    Last Post: 09-15-2009, 07:29 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