Results 1 to 2 of 2
  1. #1
    Paul-NYS is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    6

    Select distinct

    Hi


    I am trying to run a query that queries and returns several data fields with one of them being an ID field. I want to select distinct IDs only, however, I don't think just adding a 'distinct' qualifier prior the ID field will do it--the only field that I want to be distinct is the ID, the others it doesn't matter.

    Does anyone know how to add a 'distinct' qualifier to a query that just applies to one field only (the ID field)?

    Select distinct ID, firstName, lastName, DOB, City from Person where City = "NYC";

    Paul

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Is the ID field the primary key field of the table? If so, then all values would have to be unique. If it is not the primary key, then you would probably have to use an aggregate query to group by that ID field, but that would force you to use one of the aggregate functions. If you have several records with the same ID, which of those particular records do you want to show?

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

Similar Threads

  1. SELECT DISTINCT or equivalent
    By kpo in forum Programming
    Replies: 13
    Last Post: 05-20-2012, 01:45 PM
  2. Delete and/or Select Distinct records query
    By admessing in forum Queries
    Replies: 39
    Last Post: 02-14-2012, 03:50 PM
  3. How to use variable in SELECT DISTINCT
    By celtics11 in forum Access
    Replies: 1
    Last Post: 11-18-2011, 04:28 PM
  4. Replies: 8
    Last Post: 04-21-2011, 05:29 PM
  5. SELECT DISTINCT not working
    By johnmerlino in forum Queries
    Replies: 2
    Last Post: 10-25-2010, 06:48 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