Results 1 to 4 of 4
  1. #1
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596

    DISTINCT on a Union All query?

    Hi,



    I have a UNION ALL query that pulls Distinct [Name] from 6 different tables and sorts by Name.

    When I run the query - there are multiple instances of most names.

    Since I need a list that has NO duplicate Names - I did a 'Select Distnict [Name] . . . ' on my Union query & I got my list of Unique Names.

    My question is - do I have to do this in two steps like I am - or is there a way for me to make this happen in my original UNION ALL query?

    Thanks!

    Robin

  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
    Try dropping the ALL. UNION by default will eliminate duplicates; adding ALL overrides that.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Thanks, Paul.

    Dropping the ALL from my UNION ALL in the query took out the dupes just like you said it would.

    Appreciate it.
    Robin

  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
    Happy to help Robin.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Query for distinct member number
    By Lauri in forum Queries
    Replies: 1
    Last Post: 08-23-2013, 03:22 AM
  2. Union Query
    By jlclark4 in forum Queries
    Replies: 3
    Last Post: 02-25-2011, 08:21 PM
  3. Union and Group by/Distinct
    By Rixxe in forum Queries
    Replies: 3
    Last Post: 11-10-2010, 09:45 AM
  4. Please help me out with union query
    By radicrains in forum Access
    Replies: 1
    Last Post: 10-29-2010, 01:48 AM
  5. Need help with a Union Query
    By jdowdy in forum Access
    Replies: 1
    Last Post: 10-13-2009, 05:24 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