When you want to limit the results of a query based on the values in a field, you use query criteria. A query criterion is an expression that ClicknDECiDE Builder compares to query field values to determine whether to include the record that contains each value. For example, = "London" is an expression that ClicknDECiDE Vision can compare to values in a text field in a query. If the value for that field in a given record is "London", ClicknDECiDE Builder includes the record in the query results.
This topic lists several examples of query criteria. It assumes that you are familiar with designing simple select queries.
What do you want to do?
Introduction
to query criteria
Open
the ClicknDECiDE SQL Editor
Introduction to Query Criteria
A criterion is similar to a formula — it is a string that may consist of field references, operators (operator: a sign or symbol that specifies the type of calculation to perform within an expression. There are mathematical, comparison, logical, and reference operators.), and constants (constant: a value that is not calculated and, therefore, does not change. For example, the number 210, and the text "Quarterly Earnings" are constants. An expression, or a value resulting from an expression, is not a constant.).
The following tables shows some sample criteria and explains how they work. Criteria Description
Criteria |
Description |
>10 and <40 |
This criterion applies to a Number field, such as Price or UnitsInStock. It includes only those records where the Price or UnitsInStock field contains a value greater than 10 and less than 40. |
DateDiff ("yyyy", [BirthDate], Date()) > 20 |
This criterion applies to a Date/Time field, such as BirthDate. Only records where the number of years between a person's birthdate and today's date is greater than 20 are included in the query result. |
Is Null |
This criterion can be applied to any type of field to show records where the field value is null. |
As you can see, criteria can look very different from each other, depending on the data type of the field to which they apply and your specific requirements. Some criteria are simple, and use basic operators and constants. Others are complex, and use functions, special operators, and include field references.
This topic lists several commonly used criteria by data type. If the examples given in this topic do not address your specific needs, you might need to write your own criteria. To do that, you must first familiarize yourself with the full list of functions, operators, special characters, and the syntax for expressions referring to fields and literals. For more information, see the articles listed in the See also section.
Here, you will see where and how you add the criteria.
To add query criteria, perform the steps below:
Note: it is not necessary to select
the field you want to specify criteria for. You can add criteria even
if the field is not selected.
Click
the blue button
in the Criteria column to the
left of the field which you want to specify criteria for. In this example
the DATE field. The Criteria dialog
box appears.
Select
the Columns drop-down list for
the required field displayed in the format TABLE_NAME.COLUMN_NAME, in
this example, Sales.DATE (for the Sales table Date column). The default
field displayed is the field selected when you clicked a blue button.
Select the criteria condition n the Operators drop-down list.
Select one of the four tabs:Value, Column, Expression or Query which corresponds to the criteria type you want to apply.
Note
the Where tab automatically displays the SQL syntax of the criteria specified.
Where tab: concerns all the
criteria applied to direct column names.
Having tab: concerns all the
criteria applied to column names used in a Group function such as SUM,
MIN, MAX, AVG and so on.
To
add criteria, select the appropriate column, operators and criteria type
and click New. The new criteria
will be displayed in the Where tab.
Switch between the and/or statements by clicking and/or.
Apply a Not statement by selecting the appropriate row and clicking Not. To remove the Not statement, click Not again.
Combine
several criteria by selecting each row and holding down CTRL, then click
Combine parentheses
will surround the rows selected. To uncombine criteria, select the appropriate
opening parenthesis, then click Uncombine.
The Combine will be removed.
See Also |