I have a number of members in a table. The fields in the table are ID, LName, FName, Status, BeginDate, EndDate
Each member has a Status ('A','P','X','T') etc.
There can be multiple records per ID, however, the Begin and End dates will be different.
What I need to return from my query is two fold. Firstly I need to select the only one record per ID, that is, the record with the latest BeginDate (the last transaction). Secondly, I need to eliminate all records with a Status that is not either 'A' or 'P'.
Is it possible to do this in a single query? As part of my select, I had a Last(BeginDate) and then in the HAVING clause I included the IN ('A','P'). This does not work since it returns a record that is not the latest BeginDate for that member. (It actually seems to filter out the invalid Status' first and then it does the Last(BeginDate).)
Any help is appreciated. If it needs to be done in two separate queries then I still have a slight problem in that my Last(BeginDate) never seems to work.
Each member has a Status ('A','P','X','T') etc.
There can be multiple records per ID, however, the Begin and End dates will be different.
What I need to return from my query is two fold. Firstly I need to select the only one record per ID, that is, the record with the latest BeginDate (the last transaction). Secondly, I need to eliminate all records with a Status that is not either 'A' or 'P'.
Is it possible to do this in a single query? As part of my select, I had a Last(BeginDate) and then in the HAVING clause I included the IN ('A','P'). This does not work since it returns a record that is not the latest BeginDate for that member. (It actually seems to filter out the invalid Status' first and then it does the Last(BeginDate).)
Any help is appreciated. If it needs to be done in two separate queries then I still have a slight problem in that my Last(BeginDate) never seems to work.