Sorry, I\'m not sure how to phrase that and I\'m really not very good with SQL. The db engine i SQL Server Compact. I currently have this query:
SELECT *
FRO
Here's how I would do it:
SELECT s1.*
FROM Samples s1
LEFT JOIN Samples s2
ON (s1.Thread = s2.Thread and s1.HitCount < s2.HitCount)
WHERE s1.FunctionId NOT IN (SELECT CalleeId FROM Callers)
AND s2.Thread IS NULL
ORDER BY s1.ThreadId, s1.HitCount DESC
In other words, the row s1 for which there is no other row s2 matching the same Thread and having a greater HitCount.