Perhaps this ?
SELECT A.Specialty, A.Diagnosis, A.Diag_count
FROM theTable A INNER JOIN theTable B ON A.Specialty = B.Specialty AND A.Diag_count <= B.Diag_count
GROUP BY A.Specialty, A.Diagnosis, A.Diag_count
HAVING COUNT(*) <= 5
Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886