Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Queries

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

1 Lesson 5.

MS ACCESS QUERIES AND REPORTS

INTRODUCTION TO MS ACCESS QUERIES

Using a query makes it easier to view, add, delete, or change data in your Access database. Some
other reasons for using queries:

 Find specific quickly data by filtering on specific criteria (conditions)


 Calculate or summarize data
 Automate data management tasks, such as reviewing the most current data on a
recurring basis.

Major query Use


types
Select To retrieve data from a table or make calculations.
Action Add, change, or delete data. Each task has a specific type of action query.
Action queries are not available in Access web apps.

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.

BASIC STEPS TO CREATE A SELECT QUERY

Options in creating queries

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.

For each number field, choose one of the following functions:

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.

c. Min The query returns the smallest value of the field.

d. Max The query returns the largest value of the fie

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.

A query criterion is an expression that Access compares to query field values to


determine whether to include the record that contains each value.

To add criteria to an Access query,

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;

3. enter the criterion in the Criteria row for that field.

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.

CREATE A QUERY BY WORKING IN DESIGN VIEW

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.

Step 1: Add data sources

Step 2: Join related data sources

Step 3: Add output fields

Step 4: Specify criteria

Step 5: Summarize data

Step 6: View the results

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

You might also like