Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
bilety_inform_1 (1).doc
Скачиваний:
0
Добавлен:
03.08.2019
Размер:
449.54 Кб
Скачать

22. Filters and Queries

  • Filters and select queries both retrieve a subset of records from a table or another query.

  • The results of both filters and queries can be used as the source of data for forms and reports.

  • You can also sort the results of both and save the sort order for use in a later work session.

  • Both methods let you edit the data displayed in the results, if editing is otherwise permitted.

  • As a rule, you use a filter to view or edit some records temporarily in a datasheet or form. If you want to return to the subset of records at a later time, you should use a query.

  • Queries are separate database objects that appear in the Navigation Pane, while a single filter is saved with a table.

  • If you use a query, you do not need to open the table first, because a query is an object in its own right. With a filter, you must open the table first before you can view the results of the filter or design a new filter.

  • You use a query if you want to extract data from multiple tables, control which fields to display, or perform calculations on field values. None of these operations is permitted with filters.

Adding Selection Criteria

The selection criteria in queries are expressions defining a condition that must be met for the record to be included in the subset. An expression is a combination of symbols, values, identifiers, and operators used for many purposes.

Symbols used in expressions include quotation marks, colons, asterisks, and other special characters. Values can be expressed as literal values, constants, the result of a function, or an identifier. Identifiers refer to the value of a field, a control in a form or report, or a property. An operator is a symbol or word that indicates an operation to be performed on one or more elements in the expression.

23. Performing Calculations in a Query

You can perform many types of calculations in a query that are recomputed each time the query is run, so you always have current data/ results of the calculations. In a query, two types of calculations can be used: aggregate calculations and custom calculated fields. The aggregate calculations are predefined operations performed on groups of records and provide :counts,averages, and other information about field values in all records or in groups of records. The custom calculated fields create new fields in a record by combining the values in other fields in the same record. You can create new Numeric, Date, or Text fields for each record using custom calculations. For example, use the expression [Delivery_Date] – [Order_Date] to create a new field Duration. Later you can use it to calculate the average duration of delivering order.

Using Aggregate calculations (Totals) in a Query

Sum -- used to add a column of numbers.

Average -- used to find the average of a column of numbers.

Maximum -- returns the highest value in a field.

Minimum -- returns the lowest value in a field.

Count -- used to count the number of same values in a query.

Summarizing all records To summarize field values in a query, start with a select query, add the field you want to summarize, and then specify the way you want the fields summarized. [Start a new Select Query and drag the field you want to the grid. On the Design tab’s Show / Hide group, click Totals command to add the Total row to the grid. Click the Total cell in the column and choose the function from the drop-down list option.]

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