Hi All,
I have been having some trouble creating a query that pulls the last entry per specific ID so I don't have duplicates. For example: I have a database of check-ins whereby an individual is evaluated multiple times per year on housing status and so for each ID there are multiple rows of data since housing status is recorded at each check-in. I want to make a query that gives me the housing status at last/most current entry for each specific ID. I tried using DISTINCT but this still gives me duplicates sometimes (i.e. someone can have many check-ins for multiple kinds of housing status, and it just narrows it down to show one of each type of entry that is different per ID.....which I suppose is the purpose of DISTINCT haha).
Below is the SQL code I have written. I am mainly using the data from one table but needed to filter for individuals that have been marked STATUS = "Active" (which is coded as 1) which is stored in a different table hence the inner join. I also removed the records where housing status was blank/missing with "is not null" for housing status.
SELECT DISTINCT tbl_CheckIn2.ID, tbl_CheckIn2.[Housing Status]
FROM tbl_Interviews2 INNER JOIN tbl_CheckIn2 ON tbl_Interviews2.ID = tbl_CheckIn2.ID
WHERE (((tbl_CheckIn2.[Housing Status]) Is Not Null) AND ((tbl_Interviews2.STATUS)=1));
Any help is so much appreciated I have been struggling with this all day and for the life of me cant figure it out!
Thanks!!