Results 1 to 7 of 7
  1. #1
    theworm is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    7

    Help with a query

    I'm new to sql so thanks for any help. We have had a small access database created for us that tracks training records. One of the reports returns all employees who are trained in a piece of equipment. However, their cert expires every 2 years and both records show up on the database.

    Doesnt look a like a difficult query.
    SELECT Entry.FullName, Entry.ClassTaken, Entry.Datetaken, Entry.DateExpires, Entry.NowCertified, Entry.Passyeswritten
    FROM EMP INNER JOIN Entry ON EMP.FullName=Entry.FullName
    WHERE entry.dateexpires > date() and emp.activeno = false;

    What I would like to do is have only return the latest certification taken. IF somebody could give some suggestions of point to a location I would appreciate it.
    Thanks

  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,521
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    theworm is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    7
    Might be a little over my head, but I will try. Thanks for the help.

  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,521
    No problem, post back if you get stuck. Welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    theworm is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    7
    Thanks Paul for your help but as I suspected, I'm a little stuck. Here is query 1 which seems to work correctly.

    SELECT max(entry.dateexpires) AS maxdate, entry.fullname
    FROM entry
    GROUP BY entry.fullname;

    Query 2 is giving me some problems at the join, but I'm not sure where to be looking.

    SELECT Entry.FullName, Entry.ClassTaken, Entry.Datetaken, Entry.DateExpires, Entry.NowCertified, Entry.Passyeswritten
    FROM ((entry inner join maxdateexpires on entry.dateexpires = maxdateexpires.dateexpires) INNER JOIN Entry ON EMP.FullName=Entry.FullName))
    WHERE entry.dateexpires > date() and emp.activeno = false;

    Thanks again.

  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,521
    Something is amiss in there. You have EMP in the ON but never actually listed as a table, but Entry is there twice (like it's joined to itself). The parentheses are also off (2 open, 3 close). I would take the Emp table out for now, and get it working correctly without it, then add it back. Can you post the db?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    theworm is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2010
    Posts
    7
    Ok, thanks for the pointers, I will take a closer look and repost if I still need help.
    Thanks

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

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