Results 1 to 7 of 7
  1. #1
    Newtrick is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    7

    Linking Tables delivering different results

    Hello. I am creating queries to join data from various tables but the results i'm getting are different. Showing the individual queries below and what happens when i link them. Note that i have tried all the different join options and still get different data. Can anyone help?



    1. Single table query - these results are correct

    SCODE First Of Data Partners Sum Of Budget
    DBMD Verve & Groundtruth $53,333.33
    DBMV Google $26,666.67


    $80,000.00
    2. 2nd table query - these results are correct

    SCODE First Of Vendor Sum Of Cost to Client
    DBMD DBM 57,826.70
    DBMV DBM 201,889.34
    FB/IG Facebook/Instagram 239,575.61
    GGLS Google Ads 72,747.43


    572,039.08

    3. Combined Query (joined where the SCODE column which is from a separate table links both tables and set up so that all of the SCODEs are supposed to be shown but only the matching table data should be included - #2 in the join options)

    SCODE Sum Of Budget Sum Of Cost to Client
    DBMD $106,666.67 231,306.80
    DBMV $106,666.67 201,889.34

    $213,333.33 433,196.14

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,899
    Show the SQL statement of third query.
    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
    Newtrick is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    7
    Here it is. Thank you so much for your quick reply.

    SELECT DISTINCTROW SCODE.SCODE, Sum([BB buy summary access].Budget) AS [Sum Of Budget], Sum([Bobbi Lumina Access].[Cost to Client]) AS [Sum Of Cost to Client]
    FROM (SCODE INNER JOIN [Bobbi Lumina Access] ON SCODE.[SCODE] = [Bobbi Lumina Access].[SCODE]) INNER JOIN [BB buy summary access] ON SCODE.[SCODE] = [BB buy summary access].[SCODE]
    GROUP BY SCODE.SCODE;

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,899
    That does not appear to be a query that is joining those two aggregate queries to a table of SCODE unique values. If you join those two queries to a table of unique SCODE values, each row should already be unique because the queries show each SCODE only once.

    SELECT SCODE.SCODE, [Sum of Cost to Client], [Sum of Budget] FROM (SCODE INNER JOIN [BudgetSummaryQuery] ON SCODE.[SCODE] = [BudgetSummaryQuery].[SCODE]) INNER JOIN [BuySummaryQuery] ON SCODE.[SCODE] = [BuySummaryQuery].[SCODE];


    Why use First() to return a vendor name? Of what use is this?
    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.

  5. #5
    Newtrick is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    7
    Again, thanks. The SCODE file is a separate table and each of the two cost columns are linked via look up fields labeled SCODE on the table. Does that answer your question? Also, i did not code in "First()", it automatically included that when i selected fields for the query.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,899
    You say you want "set up so that all of the SCODEs are supposed to be shown but only the matching table data should be included". To accomplish this would have to INNER join the two aggregate queries to each other. Then in another query join that query to table of all SCODE values using LEFT or RIGHT JOIN.
    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.

  7. #7
    Newtrick is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    7
    SUCCESS! I am very grateful for the help. Enjoy your day.

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

Similar Threads

  1. Linking tables
    By hgdekoning in forum Access
    Replies: 5
    Last Post: 04-30-2018, 06:47 AM
  2. Linking Tables
    By hermannm in forum Access
    Replies: 4
    Last Post: 02-21-2018, 03:12 AM
  3. Linking Tables
    By spyldbrat in forum Access
    Replies: 5
    Last Post: 09-10-2015, 02:07 PM
  4. Replies: 0
    Last Post: 03-04-2011, 10:28 AM
  5. Linking Tables?
    By briancb2004 in forum Access
    Replies: 0
    Last Post: 09-29-2008, 01:14 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