Results 1 to 3 of 3
  1. #1
    mbelote0613 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Sep 2016
    Posts
    1

    Distinct query


    Trying to create a query of a single table where unique values are based on 2 of the 4 fields. HOWEVER, result of the query needs to display all 4 fields. Example 4 fields are name, date, qty and amount. I want to display all 4 fields but only where name and date are unique.
    "SELECT DISTINCT name, date FROM tablename " for the above example returns only name and date fields and I can not figure out how to include qty and amount

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    2 queries,
    Q1 sums quantities.
    Q2 uses Q1 with the 4 fields and Unique.

  3. #3
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Join your distinct query with the table and join them on the name and date fields and add the qty and amount to your SQL statement

    BTW: name and date are reserved names in Access. You would be better served giving those fields a different name as it may cause you issues in the future. To get a complete list of reserved terms. Google "MS Access reserved terms." There are many.

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

Similar Threads

  1. DISTINCT query resolution
    By shabar in forum Queries
    Replies: 8
    Last Post: 02-14-2013, 10:50 PM
  2. Distinct query?
    By Kivan in forum Queries
    Replies: 3
    Last Post: 08-29-2012, 10:16 PM
  3. distinct query
    By slimjen in forum Queries
    Replies: 4
    Last Post: 05-25-2012, 08:30 AM
  4. distinct query
    By slimjen in forum Queries
    Replies: 3
    Last Post: 02-04-2012, 04:44 PM
  5. DISTINCT on a Union All query?
    By Robeen in forum Queries
    Replies: 3
    Last Post: 04-27-2011, 10:30 AM

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