Skip to content
Advertisement

Select every rows that contains all elements of group

Column [TYPE] has A or B or C. I want to select list of names those have all A,B,C in the table.

enter image description here

Result

enter image description here

Actually, I wanted to do this with second method because that TYPES A,B,C have subtypes so risk of duplicates but I got this error below.

Msg 156, Level 15, State 1, Line 10 syntax error 'all'...

Is there any way to do this?

Advertisement

Answer

You can use group by and having:

This assumes that the name/type rows are not repeated in the table.

Edit:

If you just want to check for A/B/C, then:

Or:

if the table has duplicates.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement