Using QMF

NOT -- Present on the opposite of the condition

You can use the opposite of any condition by putting NOT before it. NOT takes precedence over AND and OR. For example, in this query, rows are selected that do not contain 38 in the DEPTNUMB column but do contain EASTERN in the DIVISION column. The other row in the Q.ORG table containing EASTERN in the DIVISION column contains 38 in the DEPTNUMB column, so it is not presented.

When you run this query:



Q.ORG | DEPTNUMB | DIVISION   | LOCATION      |
------+----------+------------+---------------|
P.    | _DEP     | _DIV       |               |
 
|        CONDITIONS            |
|------------------------------|
| NOT _DEP=38 AND _DIV=EASTERN |

QMF produces this report:

DEPTNUMB  DIVISION       LOCATION
--------  -------------  ---------
      15  EASTERN        BOSTON
      20  EASTERN        WASHINGTON

To illustrate how parentheses can change the results of a query, the first query that follows contains no parentheses. The second adds some parentheses. The third moves them a little.

When you run this query:



Q.ORG | DEPTNUMB | DIVISION   | LOCATION      |
------+----------+------------+---------------|
P.    | _DEP     | _DIV       | _LOC          |
 
|        CONDITIONS                           |
|---------------------------------------------|
| NOT _DEP=51 AND _DIV=MIDWEST OR _LOC=BOSTON |

QMF produces this report:

DEPTNUMB  DIVISION       LOCATION
--------  -------------  ---------
      15  EASTERN        BOSTON
      42  MIDWEST        CHICAGO

When you place parentheses as follows, your report is exactly the same as in the previous example.

(NOT _DEP=51 AND _DIV=MIDWEST) OR _LOC=BOSTON

However, if you move the left parenthesis after NOT, as in the following query, you get different results.

When you run this query:



Q.ORG | DEPTNUMB | DIVISION   | LOCATION      |
------+----------+------------+---------------|
P.    | _DEP     | _DIV       | _LOC          |
 
|        CONDITIONS                             |
|-----------------------------------------------|
| NOT (_DEP=51 AND _DIV=MIDWEST) OR _LOC=BOSTON |

QMF produces this report:

DEPTNUMB  DIVISION       LOCATION
--------  -------------  ---------
      10  CORPORATE      NEW YORK
      15  EASTERN        BOSTON
      20  EASTERN        WASHINGTON
      38  EASTERN        ATLANTA
      42  MIDWEST        CHICAGO
      66  WESTERN        SAN FRANCISCO
      84  WESTERN        DENVER

Rules for NOT


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]