SQL 2017 : Conversion failed when converting the nvarchar value '____' to data type int

Hi,

Running the below query in SQL throws a conversion failed error.

I'm not sure how to implement cast function to the below script. It would be great if someone can help on this.

Query:
SELECT PrjName as 'ClientName',COUNT(PrjName) AS 'NumOccurrences',Subclass as 'Type' FROM Master WITH (NOLOCK)
WHERE Alias = 'WEBDOC'
AND TYPE = 'P'
AND Subclass = 'CLIENT'
GROUP BY PrjName ,Subclass
HAVING ( COUNT(PrjName) > 1 )
union
SELECT PrjpName as 'ClientName',COUNT(PrjpName) AS 'NumOccurrences',Subclass as 'Type' FROM Master WITH (NOLOCK)
WHERE Alias = 'WEBDOC'
AND TYPE = 'P'
and PrjpName not in (0, 999999994, 999999998)
GROUP BY PrjpName ,Subclass
HAVING ( COUNT(PrjpName) > 1 )
ORDER BY 3,1

Error:
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value 'TA UPDATE' to data type int.
Warning: Null value is eliminated by an aggregate or other SET operation.

...
and PrjpName not in ('0', '999999994', '999999998')
...

Thank you, it worked :slight_smile: