Subquery to get max(date) from transaction file by customer
Posted on 2007-10-07
I have a transaction journal file with customer sales and related information.
One field is a sales code, which can change overtime, and isn't always entered (it should be mandatory input but currently isn't). I need to come up with a query that gives me a Name and the sales code from the latest dated transaction in the case where there is one, or "none" if there isn't one at all in any of the transactions for that company.
I have attempted a subquery with max(date) but it is taking forever to run....
This is what I have currently:
SELECT QTL.Name, QTL.Salescode
FROM QuickenTrxList AS QTL
WHERE (((QTL.Date)=(SELECT Max(Date) From QuickenTrxList as S WHERE S.Name = QTL.Name )));