I have a really simple scenario I just cannot get to work.
I have some sample data:
MyTable
IDNO IDCode
1 AAA
1 BBB
1 CCC
2 BBB
2 CCC
3 AAA
Current Code
SELECT DISTINCT IDNO,
CASE WHEN IDCode IN ('BBB', 'CCC') THEN 1 ELSE 0 END yesno
FROM MyTable
Current Output
IDNO yesno
1 0
1 1
2 1
3 0
What I want is to return a 1 if any of the criteria is met, even if they contain a value that isn't in the CASE criteria but contain at least 1 of them.
Expected Output
IDNO yesno
1 1
2 1
3 0
Try below using group by and max aggregation
DEMO