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. For the example, basic_where.qr
y, where StockNumber
is greater than 400000
and less than 50000,
modify the query to group constraints. The new query will retrieve results where sales in any of the 3 months is greater than 1500
units, as long as sales for each of the 3 months is greater than 1000
units.
Click Where in the Visual Query Builder. 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.
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
and then Shift+click to also select
Then click Ungroup. The three statements are no longer grouped.
Retrieving Information That Meets Specified Criteria | Presenting Results in Specified Order |
© 1994-2005 The MathWorks, Inc.