Results 1 to 5 of 5
  1. #1
    Mbmohamed is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Posts
    3

    Aggregate Data by first, second, third ...


    Can you please help?
    I want a query or SQL code to aggregate data by first_date, Second_date, third_date to be like this:


  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
    Welcome to the site. If you attached an image, it's didn't come through. Aggregation is typically done with a totals query, so you may want to search on that.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Mbmohamed is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Posts
    3
    Thanks for your reply and and appreciate your help
    Best regards
    Click image for larger version. 

Name:	Attach.png 
Views:	13 
Size:	13.5 KB 
ID:	46359

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Consider:

    TRANSFORM First(MyTable.Visit_Date) AS FirstOfVisit_Date
    SELECT MyTable.MRN
    FROM MyTable
    GROUP BY MyTable.MRN
    PIVOT "Visit_Date_" & DCount("*","MyTable","MRN='" & [MRN] & "' AND Visit_Date<#" & [Visit_Date] & "#")+1;


    Is data multi-year? No more than 3 visits per MRN?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Mbmohamed is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Posts
    3
    Quote Originally Posted by June7 View Post
    Consider:

    TRANSFORM First(MyTable.Visit_Date) AS FirstOfVisit_Date
    SELECT MyTable.MRN
    FROM MyTable
    GROUP BY MyTable.MRN
    PIVOT "Visit_Date_" & DCount("*","MyTable","MRN='" & [MRN] & "' AND Visit_Date<#" & [Visit_Date] & "#")+1;


    Is data multi-year? No more than 3 visits per MRN?
    Thank you for your reply
    Sometimes the number of visits is less than 3 and sometimes are more

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

Similar Threads

  1. Aggregate sum
    By anne4815 in forum Queries
    Replies: 1
    Last Post: 03-20-2016, 05:26 AM
  2. Replies: 1
    Last Post: 08-22-2015, 05:58 AM
  3. Mass Import from Excel to aggregate data
    By swift1 in forum Access
    Replies: 2
    Last Post: 06-16-2015, 04:47 PM
  4. Cannot Have Aggregate function
    By vitordf in forum Queries
    Replies: 4
    Last Post: 08-13-2013, 07:24 AM
  5. Aggregate and Non-Aggregate
    By dr4ke in forum Queries
    Replies: 6
    Last Post: 07-21-2012, 08:16 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