Results 1 to 3 of 3
  1. #1
    ianclark2992 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2013
    Posts
    3

    Trouble Joining Two Queries

    Hey Everyone,

    New to the forums here and I have a question. I am trying to create a report which requires me to pull the following data into a query: client name, audit name, audit status, lead manager on audit, the most recent milestone per engagement, and the milestone start and due dates. This information is found in two seperate tables

    I have written two separate queries that pull the required information from each table. However, I am having trouble joining these two queries into one without encountering an error.



    Query for Potential Pilot Engagements:

    SELECT pe.[Client Name], pe.[Audit Name], pe.[Status], pe.[IA DA Team Manager]
    FROM
    [Potential Pilot Engagements] pe

    Query for Pilot Milestones:

    SELECT pm.eid, pm.Milestone, pm.Status, pm.[Start Date], pm.[Due Date]
    FROM [Pilot Milestone] pm
    INNER JOIN
    (
    SELECT EID, MAX(ID) AS Current
    FROM [Pilot Milestone]
    GROUP BY EID
    )
    groupedpm ON pm.EID = groupedpm.EID AND pm.id = groupedpm.Current

    If anyone knows how I can resolve this issue it would be greatly appreciated.

    Thanks!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,897
    Try including AS after the nested query

    ) AS groupedpm ON
    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
    ianclark2992 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2013
    Posts
    3
    In case anyone here works on a similar query in the future I received the following help from a fellow employee

    SELECT [Potential Pilot Engagements].[Client Name], [Potential Pilot Engagements].[Audit Name], [Potential Pilot Engagements].[IA DA team Manager], [Potential Pilot Engagements].Status, pm.Milestone, pm.[Start Date], pm.[Due Date], pm.Status
    FROM [Potential Pilot Engagements]
    INNER JOIN
    ([Pilot Milestone] AS pm
    INNER JOIN
    (SELECT EID, MIN(MID) AS [Current]
    FROM
    [Pilot Milestone]
    WHERE Status<>"Completed"
    GROUP BY EID) AS groupedpm
    ON (pm.EID=groupedpm.EID) AND (pm.mid=groupedpm.Current))
    ON [Potential Pilot Engagements].EID=pm.EID;

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

Similar Threads

  1. Joining two tables
    By rspai in forum Queries
    Replies: 7
    Last Post: 05-22-2012, 12:21 AM
  2. help with joining SQL statements
    By iamstupid in forum Queries
    Replies: 2
    Last Post: 05-26-2011, 06:55 AM
  3. Help - Joining Tables..
    By fabian24 in forum Forms
    Replies: 3
    Last Post: 02-17-2011, 03:43 PM
  4. joining on two userid's
    By svcghost in forum Queries
    Replies: 9
    Last Post: 09-30-2010, 06:48 PM
  5. Joining a Query
    By access_gbr in forum Queries
    Replies: 1
    Last Post: 05-04-2010, 10:46 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