A
Andy79
Hi,
I am trying to write a query to return the most recent payment date
and how much was paid.
The database has two tables, members and payments. Any one member can
have any number of payments..
Here is where I got so far
SELECT members.memberID, payments.paymentsID,
max(payments.paymentdate) AS 'Last Payment', payments.paymentvalue
FROM members INNER JOIN payments ON members.memberID =
payments.paymentID
Where ...
And my problem is how to write the Where that will only show the
payment value from the same row as the 'max' paymentdate (ie the most
recent date a payment was made)
Because the system is being used for current payments and to record
old payments the ordering of paymentID and paymentdate doesn't match
(people are transfering old payments onto the system from paper
records) so I can't use 'select first(payments.pa...'.
Any clues as to how to write the cirteia to 'show me the payment value
from the row with the most recent date'
Thanks for your help!
Regards
Andy
I am trying to write a query to return the most recent payment date
and how much was paid.
The database has two tables, members and payments. Any one member can
have any number of payments..
Here is where I got so far
SELECT members.memberID, payments.paymentsID,
max(payments.paymentdate) AS 'Last Payment', payments.paymentvalue
FROM members INNER JOIN payments ON members.memberID =
payments.paymentID
Where ...
And my problem is how to write the Where that will only show the
payment value from the same row as the 'max' paymentdate (ie the most
recent date a payment was made)
Because the system is being used for current payments and to record
old payments the ordering of paymentID and paymentdate doesn't match
(people are transfering old payments onto the system from paper
records) so I can't use 'select first(payments.pa...'.
Any clues as to how to write the cirteia to 'show me the payment value
from the row with the most recent date'
Thanks for your help!
Regards
Andy