We are trying to track our applications in our department and our unit test usage so I have created a database to keep track of this. I have an Applications
Any of these 2 options will work for your scenario:
1 have the logic that adds the new unit test count for the application, insert the record in the history + update the application record's unit test count. Then use a simple select over the application records - history records have nothing to do in this scenario. This is best if you'll have a huge amount of records in the history.
2 use this query against the UnitTestTracking table directly
select application_id, unittestcount from UnitTestTracking u1
where date_added = (
select max(date_added) from UnitTestTracking u2
where u1.application_id = u2.application_id
)