Results 1 to 8 of 8
  1. #1
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    310

    last three payments

    Hi to all,


    I am building a database. Each month I am paying money to different people.
    How can i find the last three payment for a specific person?

    sincerely yours
    Thank you

  2. #2
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    can you use a Query:
    Code:
    SELECT TOP 3 * FROM yourPaymentTableName WHERE payee = 'TheNameOfPayee' ORDER BY PaymentDate DESC;
    
    or
    
    SELECT TOP 3 * FROM yourPaymentTableName WHERE payeeID = 1234 ORDER BY PaymentDate DESC;

  3. #3
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    310
    Thank you very much for the reply.
    Is it possible to sum them or find the average?

    Thanks

  4. #4
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    310
    Hi
    I was able to get the average.

    Code:
    SELECT TOP 3 Avg(FieldName) AS AvgOfPayment
    FROM tblHistory
    WHERE [FieldName2]='Value';
    Thank you

  5. #5
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    you should add Sort order (Descending order) on your Payment date
    to get the correct latest 3 payment records.

  6. #6
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    310
    Hi

    I tried to add the sort order as follows:
    Code:
    SELECT TOP 3 Avg(FieldName) AS AvgOfPaymentFROM tblHistory
    WHERE [FieldName2]='Value'
    ORDER BY FieldName3 DESC;
    But has the following error:
    Your query does not include the specified expression 'FieldName3' as part of an aggregation function
    Khalil

  7. #7
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    to find the Average of the Last 3 Payments, you will need this:
    Code:
    SELECT AVG(FieldName) AS AvgOfPayment 
    FROM 
    (SELECT TOP 3 FieldName 
    FROM tblHistory
    WHERE [FieldName2]='Value' ORDER BY FieldName3 DESC);

  8. #8
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    310
    Thank you very much.
    Khalil

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

Similar Threads

  1. Cumulative totals for summary payments
    By maxmaggot in forum Forms
    Replies: 2
    Last Post: 04-06-2014, 12:50 PM
  2. Replies: 1
    Last Post: 11-01-2013, 11:53 AM
  3. Invoice and payments received
    By esther6086@lowcountry.com in forum Queries
    Replies: 1
    Last Post: 08-13-2013, 06:28 PM
  4. Need To Sum Payments in Query
    By burrina in forum Queries
    Replies: 3
    Last Post: 11-27-2012, 05:35 PM
  5. Replies: 3
    Last Post: 07-18-2011, 04:14 PM

Tags for this Thread

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