Database Toolbox | ![]() ![]() |
Grouping Criteria
In the Where Clauses dialog box, you can group together constraints so that the group of constraints is evaluated as a whole in the query. Continuing with the example, basic_where.qr
y, where StockNumber
is greater than 400000
and less than 50000
, modify the query to retrieve results where sales in any of the three months is greater than 1500
units, as long as sales for each of the three months is greater than 1000
units. The Where Clauses dialog box appears as follows to retrieve data where the StockNumber
is greater than 400000
and less than 50000
.
StockNumber < 500000
, and then click Edit.
OR
, and then click Apply.
January
. For Relation, select >
and type 1500
in the field
for it. For Operator, select OR
, and then click Apply.
February
. For Relation, select >
and type 1500
in the
field for it. For Operator, select OR
, and then click Apply.
March
. For Relation, select >
and type 1500
in the field
for it. Then click Apply.
January >1500 OR
.
February > 1500 OR
.
March > 1500
.
An opening parenthesis, (, is added before January
, and a closing parenthesis, ), is added after March > 1500
, signifying that these statements are evaluated as a whole.
March >1500)
and then click
Edit.
AND
, and then click Apply.
January
. For Relation, select >
and type 1000
in the field
for it. For Operator, select AND
, and then click Apply.
February
. For Relation, select >
and type 1000
in the
field for it. For Operator, select AND
, and then click Apply.
March
. For Relation, select >
and type 1000
in the field
for it. Then click Apply.
The Where Clauses dialog box closes. The SQL statement in the Visual Query Builder dialog box reflects the modified where clause. Because the clause is so long, you have to use the right arrow key in the field to see all of the contents.
Removing Grouping. To remove grouping criteria in the Where Clauses dialog box, in Current clauses, select all of the statements in the group and then click Ungroup. The parentheses are removed from the statements.
For the above example, to remove the grouping, select (January > 1000 AND
, and then Shift-click to also select February > 1000 AND
, and March > 1000)
. Then click Ungroup. The three statements are no longer grouped.
![]() | Retrieving Information That Meets Specified Criteria | Presenting Results in Specified Order | ![]() |