SELECT ogr.MemberID
,pt.PopulationTaskID
,COUNT(pt.PopulationTaskID) As GapCount
FROM OutcomeGapResult ogr
INNER JOIN PopulationTask pt ON pt.PopulationTaskID=ogr.PopulationTaskID
LEFT OUTER JOIN [Population] p ON p.MemberID=ogr.MemberID
WHERE pt.Active=1
GROUP BY ogr.MemberID,pt.PopulationTaskID
HAVING GapCount=1
ORDER BY ogr.MemberID
|