Skip to content
Advertisement

How to write a query with WHERE with two conditions

Right now I have:

WHERE flag_1 NOT IN ("D") AND flag_2 NOT IN ("D")

I have two sets of people working on the same data, and once one group is completed they will “flag” it D, but the report will still need to pull the info until BOTH are flagged D.

Right now the report is excluding the data if either are flagged D, but I only want it excluded once both aspects are completed and flagged D.

Any guidance?

Advertisement

Answer

I only want it excluded once both aspects are completed and flagged “D”.

This would translate as:

WHERE NOT (flag_1 = 'D' AND flag_2 = 'D')

NB: I don’t see the point for the IN operator with a single value in the list, so I changed to a simple =.

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