Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
sec2_second_term_2013_doc.doc
Скачиваний:
0
Добавлен:
01.07.2025
Размер:
1.84 Mб
Скачать

Royal International Language School

Computer (Sec.2)

Second Term

Chapter six queries

We use queries to view, change, and analyze data in different ways. You can also

use them as a source of records for models, and reports. There are several types of

queries in Microsoft Access.

A select query is the most common type of query. It retrieves data from one or more

tables and displays the results in a datasheet where you can update the records (with

some restrictions).

You can also use a select query to group records and calculate sums, numbers,

averages, and other types of totals.

2-Parameter queries

A parameter query is a query that displays its own dialog box promoting for

information, such as the criteria for retrieving records or a value you want to insert in

a field. You can design the query to prompt for more than a piece of information; for

example, you can design it to prompt for two dates. Access can then retrieve all

records that fall between those two dates.

3-Cross tab queries

You use cross tab queries to calculate and restructure data for easier analysis of

your data. Cross tab queries calculate a sum, average, count, or other types of totals

for data that are grouped by two types of information — one at the left side of the

datasheet and another across the top.

4-Action queries

An action query is a query that causes changes to many records in just one

operation. There are four types of action queries:

Delete Queries:

A delete query deletes a group of records from one or more than a table. For

example, you can use a delete query to remove unnecessary products that are no

longer used. With delete queries, you always delete entire records, not just

selected fields within records.

Update Queries :

An update query makes global changes to a group of records in one or more

than a table. For example, you can raise prices by 10 per cent for all dairy

products, or you can raise salaries by 5 per cent for people within a certain job

category. With an update query, you can change data in existed tables.

Append Queries:

An append query adds a group of records from one or more than a table at the

foot of the table. For example, suppose that you acquire some new customers and

a database containing a table of information on those customers, to avoid typing

all this information into your own database, you can append it to your Customers

table.

Make-Table Queries:

(Make-table query) creates a new table from all or from a part of data in one or

more than a table. (Make-table queries) are helpful for creating tables to export to

another Microsoft Access database or a history table that contains old records.

We will concentrate on the select query, as they are the most common types

Creating a query using the wizard

Exercise 1: Design a query to display (employee number, name and salary)

As you have learnt, open the company database.

Select Queries from the database window.

As illustrated in the previous figure select (Create Query) using Wizard

Or Click (New ) so the following window appears:

Select (Simple Query Wizard) so the following dialogue box appears.

From the previous dialogue box, the possibility of selecting fields from more than a

Table is evident. Select the required tables as shown:

Select next

The previous window enables you to display all the records. It is the (Default) option.

Click finish, so the following query appears as in the following figure:

The previous window shows the required data in datasheet, try to remember the

components of the previous window that we have dealt with, on displaying the data of

the table.

Creating a Query without the wizard:

Exercise 2: Design a Query that displays (department code - department nameemployee

name and main salary) then save it as (e1). Select (Queries) from the

database window then select (New). Choose queries and choose new as in the

following figure:

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]