Topics: |
So far, you have written report requests that retrieve all records available in the EMPLOYEE data source for the fields you specify. Using the WHERE keyword, you can limit the records retrieved by specifying conditions a record must meet in order to be retrieved.
You use WHERE to begin a conditional statement. You create a condition by comparing a field or calculation to a test value, another field, or a calculation you supply. You can include several conditions in a single request.
You create a conditional statement using the following format:
WHERE field relational_operator {test_value|field|calculation}[;]
In the above structure, if you supply a test value, it is the value to which each record is compared. If you supply a field, it can be alphanumeric or numeric as long as the data type is the same as the field name to the left of the relational operator. If you supply a calculation, it can be a mathematical formula or alphanumeric manipulation.
The relational operator enables you to determine the type of comparison between the field and any of the components to the right of the operator. When the value is retrieved from the data source, it checks each value to see if it meets the condition you specified. Only values that satisfy the condition or conditions are included in the report. To retrieve values that do not satisfy conditions, use the NOT operator in front of the expression.
When you include WHERE in your request to describe screening conditions, remember the following rules:
Note: You can include screening conditions in a procedure, Master File, or filter file.
The following table includes a partial list of relational operators and the types of comparisons they perform.
Relational Operator |
Type of Comparison |
---|---|
GT |
Greater than. |
LT |
Less than. |
EQ |
Equals. |
NE |
Not equal. |
GE |
Greater than or equal to. |
LE |
Less than or equal to. |
LIKE |
Selects values containing test character strings. |
For instance, if you want to retrieve records that are greater than the specified test value, field, or calculation, you use the GT (greater than) operator. If you want to retrieve only records that are less than the specified component, you use the LT (less than) operator.
Another type of operator you use in conditional statements is the logical operator. There are two logical operators, AND and OR. You use these logical operators to connect more than one condition. If you want each and every condition satisfied before a record is retrieved, you connect them using AND. If you want at least one of the conditions to be met for a record to be retrieved, you connect the conditions using OR.
WebFOCUS | |
Feedback |