|
Introduction to Queries
Various Types of QueriesSelect QueryA 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, counts, averages, and other types of totals. Parameter QueryA parameter query is a query that when run displays its own dialog box prompting you for information, such as criteria for retrieving records or a value you want to insert in a field. You can design the query to prompt you for more than one piece of information; for example, you can design it to prompt you for two dates. Microsoft Access can then retrieve all records that fall between those two dates. Parameter queries are also handy when used as the basis for forms and reports. For example, you can create a monthly earnings report based on a parameter query. When you print the report, Microsoft Access displays a dialog box asking for the month that you want the report to cover. You enter a month and Microsoft Access prints the appropriate report. Crosstab QueryA crosstab query displays summarized values (sums, counts, and averages) from one field in a table and groups them by one set of facts listed down the left side of the datasheet and another set of facts listed across the top of the datasheet. Example of a crosstab queryCrosstab queries calculate a sum, average, count, or other type of total for data that is grouped by two types of information one down the left side of the datasheet and another across the top.
Action QueryAn action query is a query that makes changes to many records in just one operation. There are four types of action queries: delete, update, append, and make-table. Delete QueryDeletes a group of records from one or more tables. For example, you could use a delete query to remove products that are discontinued or for which there are no orders. With delete queries, you always delete entire records, not just selected fields within records. Update QueryMakes global changes to a group of records in one or more tables. For example, you can raise prices by 10 percent for all dairy products, or you can raise salaries by 5 percent for the people within a certain job category. With an update query, you can change data in existing tables. Append QueryAdds a group of records from one or more tables to the end of one or more tables. 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 in, you'd like to append it to your Customers table. Make-table QueryCreates a new table from all or part of the data in one or more tables. Method to Create a Select Query
Method to Create a Parameter QueryCreate a parameter query that prompts for criteria each time it's run
Assignment 3 |