I am trying to filter data using count. For a given day and patient, I would like to return all the valid tests. When I use a count this way, it only returns the patients with at least 4 tests. I want it to display those patients that have 1, 2, 3, or 4 valid tests, but not if 5, 6 or .... we taken on a given day. I only need the first four valid tests. Any suggesions?
SELECT Sheet1$.[Patient ID]
FROM M_PWA INNER JOIN
Sheet1$ ON M_PWA.DATETIME = Sheet1$.DATETIM E
WHERE (Sheet1$.[Operator Index] >= 90)
GROUP BY Sheet1$.[Patient ID]
HAVING (COUNT(*) <= 4)
SELECT Sheet1$.[Patient ID]
FROM M_PWA INNER JOIN
Sheet1$ ON M_PWA.DATETIME = Sheet1$.DATETIM E
WHERE (Sheet1$.[Operator Index] >= 90)
GROUP BY Sheet1$.[Patient ID]
HAVING (COUNT(*) <= 4)
Comment