exclude all rows for an ID if 1 row meets condition
问题 I am trying to select certain customers from a contacts table if they do not have a guardian listed. ClientId | ContactId | Guardian 123 | 1 | Y 123 | 2 | N 123 | 3 | N 456 | 4 | N 456 | 5 | N 456 | 6 | N Desired output: ClientId | ContactId | Guardian 456 | 4 | N 456 | 5 | N 456 | 6 | N So my goal is that Client 456 would show up in my query results, but not Client 123. I have written the following: select * from Contacts where Guardian <> (case when Guardian = 'Y' then Guardian else '' end)