Queries
What queries do
A query retrieves, filters, sorts and calculates data from one or more tables. In a select query you choose fields, set criteria, choose sort order, and optionally use aggregate functions such as count, sum, average, minimum and maximum. Criteria use operators: comparison (=, >, <, >=), logical (AND, OR, NOT), and pattern matching with wildcards. Understand that AND narrows results (all conditions true) while OR broadens them (any condition true). Know that text criteria need quotes and dates need date delimiters, and that null values behave differently from zero or blank text.
Types of query
Know select queries, parameter queries (prompt the user for a value at run time), action queries (update, append, delete, make-table) and calculated fields using expressions. Understand that an action query changes data and cannot be undone by simply rerunning it, so a backup is wise. Crosstab queries summarise data in a grid.
Traps
Examiners test operator precedence and grouping: a query with OR mixed with AND can return unexpected rows unless conditions are bracketed. Another trap is confusing filtering in a table with a saved query, or assuming a query stores data (it stores the definition, not the results). Watch for questions on wildcards: the asterisk matches any number of characters, the question mark matches a single character.
Rule of thumb
Read criteria left to right and bracket every OR group: (A OR B) AND C is not the same as A OR (B AND C).