![]() Previous |
![]() Next |
A Boolean expression is a three-part clause that consists of two items to be compared, separated by a comparison operator. You can create a more complex Boolean expression by joining any of these three-part expressions with the AND and OR logical operators. Each expression that is connected by AND or OR must be a complete Boolean expression in itself, even when it means specifying the same variable several times.
For example, the following expression is not valid because the second part is incomplete.
sales GT 50000 AND LE 20000
In the next expression, both parts are complete so the expression is valid.
sales GT 50000 AND sales LE 20000
When you combine several Boolean expressions, the whole expression must be valid even when the truth value can be determined by the first part of the expression. The whole expression is compiled before it is evaluated, so when there are undefined variables in the second part of a Boolean expression, you get an error.
Use the NOT operator, with parentheses around the expression, to reverse the sense of a Boolean expression.
The following two expressions are equivalent.
district NE 'BOSTON' NOT(district EQ 'BOSTON')
Example 2-2 Using Boolean Comparisons
The following example shows a report that displays whether sales in Boston for each product were greater than a literal amount.
LIMIT time TO FIRST 2 LIMIT geography TO 'BOSTON' REPORT DOWN product ACROSS time: f.sales GT 7500
This REPORT statement returns the following data.
CHANNEL: TOTALCHANNEL
GEOGRAPHY: BOSTON
---F.SALES GT 7500---
--------TIME---------
PRODUCT Jan02 Feb02
-------------- ---------- ----------
Portaudio NO NO
Audiocomp YES YES
TV NO NO
VCR NO NO
Camcorder YES YES
Audiotape NO NO
Videotape YES YES