Was this helpful?
Comparison Operators
A comparison operator is a binary operator that takes two expressions as operands. Both expressions must be of the same type—numeric, string, or date. The following operators are recognized:
Operator
Description
=
equal to
!= or <>
not equal to
>
greater than
>=
greater than or equal to
<
less than
<=
less than or equal to
All comparisons are of equal precedence. When comparisons involving character strings are made, all blanks are ignored.
Conditional Expressions
A conditional expression has the form:
expr comp_op expr
The expr is an expression, and comp_op is a comparison operator.
An expression can be enclosed in parentheses without affecting its interpretation, as in the following examples:
(age < 50)
((salary * 12) >= 20000)
A conditional expression evaluates to true or false. It can contain partial match specification characters.
Pattern Matching with Wildcards
You can indicate partial matches of character string data in a conditional clause in an .if statement and in the where clause of a query by using special wildcard characters with the comparison operators. The character string data must be delimited by single quotes (except when used in a QUEL query).
Wildcards in an .If Clause
When used in a string within an .if condition, the special meaning of wildcard characters can be disabled by preceding them with a backslash (\) character. Report-Writer then interprets the wildcard character literally. Thus, \* refers to the asterisk character. When used outside of an .if condition, wildcard characters have no special meaning and are always interpreted literally.
You can use the following wildcard characters within a conditional clause in an .if statement for the purpose of comparing character string data:
Character
Description
*
Matches any string of zero or more characters
?
Matches any single character
[..]
Matches any of the characters in the brackets
Any of these special characters can be used alone or in combination to specify partial match criteria:
Example
Description
ename = '*'
Matches all values in the "ename" column
ename = 'E*'
Matches any value beginning with "E"
ename = '*ein'
Matches any value ending with "ein"
ename = '*[aeiou]*'
Matches any value with at least one vowel
ename = 'Br???'
Matches any five-character value beginning with "Br"
ename = '[A-J]*'
Matches any value beginning with A, B, C, ..., J
ename = '[N-Z]???'
Matches any four-character value beginning with N, O, P, ..., Z
You cannot use blanks in bracketed expressions such as "[A‑J]*" or "[N-Z]???".
Wildcards in Queries
When a string appears within the where clause of a .query statement, the wildcard conventions must follow those of the database query language you are using to retrieve the data.
Last modified date: 11/28/2023