Results 1 to 5 of 5
  1. #1
    tonydepo is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    28

    Post Help fast!!! Distinct value Query focusing on 2 fields, but showing all fields..

    Ok, I am on a time constraint and really appreciate some help. I have one table "Data" with multiple fields.

    Fields:
    Acct
    Zip
    Street
    Date


    Sample data:
    12455 48185 29 KAK Drive 01/01/2012
    12455 48185 32 Smalls Drive 01/02/2012
    12455 48185 19 Lake drive 01/02/2012
    26899 45333 20 Lilly lane 03/03/2012
    26899 45999 15 Jacboson ln 03/03/2012


    I want to create a query for results that are as follows (1st row with focusing on Acct/ZIP only, but return the entire record):

    12455 48185 29 KAK Drive 01/01/2012


    26899 45333 20 Lilly lane 03/03/2012


    Please Help.... Thank you so much. I tried messing around with First for totals and no luck.

    Thanks

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    What is your determination as to what determines the first row (record). What criteria do you want to use as a basis of selection?

  3. #3
    tonydepo is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    28
    1st 2 Fields for my unique values and display the rest of the record.

    Thanks
    Reply

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    I am not understanding. What determines the first record. In access, data is stored randomly. It is not like spreadsheet. Just because a table looks like a spreadsheet, the order of the records is not necessarily the order in which they are seen. You need to determine what makes a particular record first. Think of a table as a big barrel that you throw data into. You want to retrieve the data in some orderly fashion. Often times it can be on a value (highest, lowest, etc.) or a date (earliest, latest, etc.). I am not grasping what determines in your case what should be first. In your example, the first three records have the same values for account and zip so how would you determine if you had to pull them out of the barrel which one was first?

    If you want to use the date as your criteria, ie. earliest date, then perhaps these two queries will do it for you.

    Code:
    SELECT Sheet1.Accnt, Sheet1.Zip, Min(Sheet1.Date1) AS MaxOfField4
    FROM Sheet1
    GROUP BY Sheet1.Accnt, Sheet1.Zip;
    
    SELECT Query1.Accnt, Query1.Zip, Sheet1.Address, Sheet1.Date1
    FROM Query1 LEFT JOIN Sheet1 ON (Query1.MaxOfField4 = Sheet1.Date1) AND (Query1.Accnt = Sheet1.Accnt) AND (Query1.Zip = Sheet1.Zip);
    Alan
    Attached Files Attached Files

  5. #5
    tonydepo is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    28
    It would be based on date. Thanks

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

Similar Threads

  1. Replies: 12
    Last Post: 05-07-2012, 12:41 PM
  2. Replies: 2
    Last Post: 12-16-2010, 02:46 PM
  3. Report showing non-visible fields
    By AKQTS in forum Forms
    Replies: 2
    Last Post: 09-21-2010, 09:40 AM
  4. fields not showing up in Form view
    By eroy in forum Forms
    Replies: 3
    Last Post: 08-28-2010, 05:44 PM
  5. Replies: 5
    Last Post: 03-20-2010, 08: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