Results 1 to 2 of 2
  1. #1
    VAer is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2016
    Location
    USA
    Posts
    163

    Hyperion query

    See attached file.

    My question is more related to SQL, I am not familiar with database, so I am trying to describe my goal as clearly as possible.

    Two tables: Table 1 and Table 2, table 1 has 3 fields and table 2 has 3 fields.

    Now I have two queries: query 1 is based on table 1 only; query 2 is based on table 2 only. Query 2 is the result when "ABC=63 and XYZ=K0"; query 1 is the result when "ABC=63". Table 1 does NOT have the field XYZ, so it is not able to set XYZ=K0.
    The result in query 2 field DEF is unique, there is no duplicate; but for query 1, there are duplicates in field DEF, you can see 3 R1, 3 R2, 2 R3, 2 R4, 2 R5.

    Table 1 is a much bigger set, table 2 is smaller set, the joint set is {R2,R3, R4}.
    {R1, R5}: In query 1 but not in query 2
    {R7}: In query 2 but not in query 1

    The joint set is the exact information I need, based on these two tables, how should I write the SQL code to get the result? I mean the code like: SELECT .... FROM .... WHERE.....; Since it is big database, there are also many rows in query 2, so I can NOT change query 1 by adding "DEF=R2 or DEF=R7 or DEF=R3 or DEF=R4".



    I do mean SQL code, since I would like to pull the joint set automatically (programming).

    Any comments?
    Attached Thumbnails Attached Thumbnails Query.JPG  

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Still not quite clear what you want. You want to return a unique record for each DEF value but only those that are in both queries? Don't need the OPQ or XYZ fields? Maybe:

    SELECT Query1.ABC, Query1.DEF
    FROM Query2 INNER JOIN Query1 ON (Query2.DEF = Query1.DEF) AND (Query2.ABC = Query1.ABC)
    GROUP BY Query1.ABC, Query1.DEF;
    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.

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