Can someone please help me with this as I'm struggling to get my head around it.
I've got a rather large query here with a number of joins, the one I'm struggling with needs to link to a file which has separate date and time fields - I need to retrieve the latest record in this file for the other matching keys..
So for example, my file had a number of fields - I'll simplify a bit.
[ClientFile]
FirstName
LastName
Address
[PaymentFile]
FirstName
LastName
PayAmount
PayDate
PayTime
I want to link from ClientFile to PaymentFile so I would try something along the line of..
But if my payment file had a number of entries for a client that would return all of those entries, I only want to return the most recent. I know I could use MAX(PayDate) but I'm struggling to get my head around how to get the may date and time to link my two files together.
Can anyone help?
** And no I can't just create a Timestamp field holding both values together - that would be the easy option but I'm stuck with the data I have got! **
I've got a rather large query here with a number of joins, the one I'm struggling with needs to link to a file which has separate date and time fields - I need to retrieve the latest record in this file for the other matching keys..
So for example, my file had a number of fields - I'll simplify a bit.
[ClientFile]
FirstName
LastName
Address
[PaymentFile]
FirstName
LastName
PayAmount
PayDate
PayTime
I want to link from ClientFile to PaymentFile so I would try something along the line of..
Code:
SELECT A.FirstName, A.LastName, B.PayDate, B.PayTime, B.PayAmount
FROM ClientFile A Join PaymentFile B on A.LastName = B.LastName and
A.FirstName = B.FirstName
Can anyone help?
** And no I can't just create a Timestamp field holding both values together - that would be the easy option but I'm stuck with the data I have got! **



-->
)
Comment