I have a request like this
SELECT Id ,sum(CASE WHEN ErrorId NOT IN ( ,10 ,11 ,12 ,13 ) THEN 1 ELSE 0 END) errorCount FROM Table group by Id
I don’t like the hard list of identifiers and I have a simple request that will get me what I want
SELECT Id ,sum(CASE WHEN ErrorId NOT IN ( select ErrorId from Errors where ErrorCategory = 'Ignore_Error' ) THEN 1 ELSE 0 END) errorCount FROM Table group by Id
However, when I try to do this, I get
Cannot perform aggregate function for expression containing aggregate or subquery.
What is my best way forward?
source share