Queries
Queries
Queries
Using a query makes it easier to view, add, delete, or change data in your Access database. Some
other reasons for using queries:
SELECT QUERY
You can use a SELECT QUERY if you want to review data from only certain fields in a table, or
review data from multiple tables simultaneously or to see the data based on certain criteria. You
can use tables and other select queries as data sources for a select query.
You can create a select query by using the Query Wizard or by working in Design view. Some
design elements are not available when you use the wizard, but you can add these elements later
by using Design view.
1. Choose the tables or queries that you want to use as sources of data.
2 Lesson 5.MS ACCESS QUERIES AND REPORTS
2. Specify the fields that you want to include from the data sources.
3. Optionally, specify criteria to limit the records that the query returns. or you can also
summarized your numeric data based on the options below
Summary Options dialog box, specify which fields you want to summarize, and how
you want to summarize the data. Only number fields are listed.
a. Sum The query returns the sum of all the values of the field.
b. Avg The query returns the average of the values of the field.
4. Run the QUERY to see the results under the Datasheet View.
QUERY CRITERIA
Query criteria help you zero in on specific items in an Access database. If an item
matches all the criteria you enter, it appears in the query results.
1. Open the query in Design view and identify the fields (columns) you want to specify
criteria for.
2. If the field is not in the design grid, double-click the field to add it to the design grid
and then;
Example:
Criteria Description
>25 and <50 This criterion applies to a Number field, such as Price or
UnitsInStock. It includes only those records where the Price or
3 Lesson 5.MS ACCESS QUERIES AND REPORTS
Criteria Description
UnitsInStock field contains a value greater than 25 and less
than 50.
DateDiff This criterion applies to a Date/Time field, such as BirthDate.
("yyyy", Only records where the number of years between a
[BirthDate], person's birthdate and today's date is greater than 30 are
Date()) > 30 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.
You can use Design view to manually create a select query. When you use Design view, you
have more control over the details of the query design.
Reminder:
If you use fields from data sources that are not related to each other, the Query Wizard
asks you if you want to create relationships. The wizard opens the Relationships
window for you, but you must restart the wizard if you edit any relationships. Therefore,
before you run the wizard, consider creating any relationships that your query needs.
Reference:
4 Lesson 5.MS ACCESS QUERIES AND REPORTS
https://support.microsoft.com/en-us/office/create-a-simple-select-query