Skip to content
Advertisement

Find groups that are missing values of one column

Hopefully someone can send some light on an issue I’m trying to resolve.

Types

Codes

I would like to be able to determine those Code/ID pairs that are missing a particular type. The result of this query should yield.

Advertisement

Answer

You need conditional aggregation for this:

Another option is to cross join the possible IDs with the Types, then EXCEPT to remove the existing ones. Problem is, this means scanning the table twice:

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