1

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?

GMB
  • 216,147
  • 25
  • 84
  • 135

3 Answers3

5

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 =.

GMB
  • 216,147
  • 25
  • 84
  • 135
2
WHERE flag_1 <> 'D' OR flag_2 <> 'D'

If you want the report to continue to pull the records until both flags are at 'D', checking the flags that don't equal 'D' will pull them into the set.

MarredCheese
  • 17,541
  • 8
  • 92
  • 91
1

Or you could translate it to WHERE flag_1 <> 'D' AND flag_2 <> 'D'. You can use the SQL IN condition (sometimes called the IN operator) if you want to easily test if an expression matches any value in a list of values. In your case you have only one single value to evaluate.

NOT is a negation, <> (not equal to) is a comparison operator, they are both ISO standard. And have no performance difference.

Junius
  • 589
  • 2
  • 12
  • 41