Skip to content
Advertisement

Identify rows with particular value across multiple columns

Each row has an Id and a Category Presence/Status combo. Sample code:

Produces:

So each row can have an “Alpha” (true/false) and a corresponding Status for “Alpha” (Pending, Approved, etc.). The same for the other categories (Beta and Charlie). Categories that are vacant always have a status of “Open”. For example, row with Id=1 has Category_Beta=0 (False), so corresponding Status_Beta is “Open”.

I have provided 3 categories in the example (Alpha, Beta, Charlie), but my actual data has over 40 categories. I want to find rows where ALL non-vacant categories are “Approved”. In the provided example, this would be rows 1 and 4.

Advertisement

Answer

This would just be a complicated where clause:

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