Results 1 to 6 of 6
  1. #1
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    434

    Query unique values with top value

    hi,
    i have this table called people in which i have many messages from many people

    i want the result as in "popleQuery" in which i have only the last message from the person, so it is a unique value in which i have only one message per person, and it is the latest message.


    how may i do this?
    thanks
    https://hhfinanza-my.sharepoint.com/...H8dUg?e=j6dHc5

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Create a "Totals" query. Group By your people field. Select Max for your date field.

    For more specific help, we would need the names of your table and the relevant fields.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    perhaps something like

    Code:
    SELECT People.*
    FROM People INNER JOIN (SELECT PersonID, Max(mDate) as MaxDate FROM People GROUP BY PersonID) M ON People.PersonID=M.PeopleID AND People.mDate=M.MaxDate

  4. #4
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    434
    it was supereasy. i made GroupBy for person, position and company, max for message date and last for message content..
    so i have only one person (i groupedby also position and company for omonimia case) with the latest message and the last content message.
    i think it's correct
    thanks
    ps great forum, the best for access i'll be a usual customer

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    be aware, last depends on order. It is not a guarantee to be the last message entered (or for that user).

  6. #6
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    434
    Click image for larger version. 

Name:	Cattura.PNG 
Views:	17 
Size:	11.7 KB 
ID:	41647
    this is my query. my real interest is to get the latest date message (data messaggio in italian), i choose "last" in messaggio (message) field just cause i had to select an aggregation, i don't mind very much to have the last message, i care to have every persons just once and the last date of message if they sent me a message..
    thanks

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

Similar Threads

  1. Replies: 5
    Last Post: 09-22-2015, 12:18 PM
  2. Unique Values in Query
    By genedi in forum Access
    Replies: 2
    Last Post: 09-09-2015, 04:51 PM
  3. Counting unique values in a query
    By DHIGHTO in forum Queries
    Replies: 4
    Last Post: 01-21-2015, 08:19 AM
  4. Replies: 3
    Last Post: 02-24-2014, 02:19 PM
  5. Limiting Query Results to Unique Values
    By orangeman2003 in forum Queries
    Replies: 2
    Last Post: 12-25-2013, 01:08 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