Results 1 to 11 of 11
  1. #1
    rncarterjm is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    9

    UNION qry dont work as expected.

    I am new to MS Access, I am working on creating a soccer DB but I am stuck on league standing query. The query in question is designed to return the summarized points, scores, needed to complete the league standing but it is returning the TeamID # instead of the Team Names. Please advise.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Have to include the teams table in query by joining on the PK/FK team ID fields. This will make related team info such as the name available.
    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
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Hard to say without knowing your table structure. Sounds like you need to join another table into the UNION query to get the names.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    rncarterjm is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    9
    here are the qry

    --qryScoresHome
    SELECT Table1.Home AS Team, Points([HomeGoal],[AwayGoal]) AS Point, Table1.HomeGoal AS Scored, Table1.AwayGoal AS Against, [Scored]-[Against] AS Agg
    FROM Table1;

    --qryScoresAway
    ---qryStandings
    SELECT qryTotal.Team, Sum(qryTotal.Point) AS SumOfPoint, Sum(qryTotal.Scored) AS SumOfScored, Sum(qryTotal.Against) AS SumOfAgainst, Sum(qryTotal.Agg) AS SumOfAgg
    FROM qryTotal
    GROUP BY qryTotal.Team
    ORDER BY Sum(qryTotal.Point) DESC , Sum(qryTotal.Agg) DESC , Sum(qryTotal.Scored) DESC;

    ---qryTotal
    ---UNION qry
    select * from qryScoresAway
    UNION select * from qryScoresHome;

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  6. #6
    rncarterjm is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    9
    database attached...
    Attached Files Attached Files

  7. #7
    rncarterjm is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    9
    .mdb format attached
    Attached Files Attached Files

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Either join tblTeams into each of the SELECT queries or join it to the UNION.

    SELECT test.*, tblTeams.[Team Name]
    FROM tblTeams INNER JOIN test ON tblTeams.TeamID = test.Team;
    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.

  9. #9
    rncarterjm is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    9
    June7, your suggestion didn't work

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    It does for me. What happens for you?
    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.

  11. #11
    rncarterjm is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    9
    Quote Originally Posted by June7 View Post
    It does for me. What happens for you?

    I got it to work, i had a syntax error.

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

Similar Threads

  1. Where two things DONT match
    By stephenaa5 in forum Queries
    Replies: 3
    Last Post: 11-09-2012, 03:51 PM
  2. macros in subform dont work
    By tuyo in forum Access
    Replies: 2
    Last Post: 03-25-2011, 09:49 AM
  3. Oat-so-simple but i dont have a clue
    By turbo910 in forum Forms
    Replies: 13
    Last Post: 11-26-2009, 12:28 PM
  4. Criteria from Combobox dont work.
    By Ryan in forum Queries
    Replies: 3
    Last Post: 08-31-2009, 07:09 AM
  5. Replies: 0
    Last Post: 12-28-2008, 01:56 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