I have the following query:
SELECT PERSON_ID
FROM TABLE
WHERE YEAR > 2013
AND ACTION = 'TERM'
GROUP BY PERSON_ID
HAVING COUNT(ACTION) = 1
This query is returning PERSON_IDs with one TERM action among other actions.
How can I modify my HAVING clause to have the query return PERSON_IDs with one TERM action and no other actions? I tried moving the AND ACTION = 'TERM' below the HAVING line, but, as there is no GROUP BY operation in that line, I am getting an error.
Here is one method: