Several cute ways to get what you want have been introduced. Personally, I like to follow simple approaches unless performance requires otherwise. This seems to me the clearest:
SELECT DISTINCT T1.zip FROM MyTable T1 WHERE NOT EXISTS (SELECT * FROM MyTable T2 WHERE T2.zip = T1.zip AND T2.entity <> 'C')
The advantage of this, IMO, is that it does not see the code, what it is trying to do, so when you look at the code again after six months, you will not scratch your head.
Tom h
source share