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
I think people seem to be making this harder than it is.
To resolve this you need two queries:
SQL for the first is:
SELECT application_ID, MAX(date_added) AS lastDateAdded FROM UnitTestTracking GROUP BY application_ID
For the second we make this work by nesting queries:
SELECT
SUM(unittestcount)
FROM
UnitTestTracking JOIN
(SELECT
application_ID, MAX(date_added) AS lastDateAdded
FROM
UnitTestTracking GROUP BY application_ID) T
ON UnitTestTracking.application_ID = T.application_ID AND
UnitTestTracking.date_added = T.LastDateAdded
And that should give you what you need i.e. the current total number of unit tests.