Access - Introduction to Queries

Similar documents
Creating a Crosstab Query in Design View

Microsoft Access XP Queries. Student Manual

Using Microsoft Access

Microsoft Office 2010: Introductory Q&As Access Chapter 2

Microsoft Access 2010

Enforce Referential. dialog box, click to mark the. Enforce Referential. Integrity, Cascade Update Related Fields, and. Cascade Delete Related

Microsoft Access Illustrated. Unit B: Building and Using Queries

Microsoft Access 2007 Lesson 2: Retrieving Information from a Database

Using Microsoft Access

Microsoft Access 2013

Microsoft Access 2013

Objective 1: Familiarize yourself with basic database terms and definitions. Objective 2: Familiarize yourself with the Access environment.

Microsoft Office Illustrated Introductory, Building and Using Queries

Access 2003 Introduction to Report Design

Complete Quick Reference Summary

Introduction to Queries

Microsoft Access XP (2002) - Advanced Queries

DESIGNING, BUILDING, AND USING DATABASES (BEGINNING MICROSOFT ACCESS, X405.4)

Access Intermediate

Access Intermediate

TECHNOLOGY COMPETENCY ASSESSMENT MODULE Microsoft Access

As your databases continue to evolve, you will need to incorporate advanced queries and reports. This chapter addresses how to create and use action

Microsoft Office Access Learn how to use the Query window in Design view. Tutorial 3b Querying a Database

MIS Cases: Decision Making With Application Software, Second Edition. Database Glossary

Microsoft Access Lesson 2: Retrieving Information from a Database

Microsoft Access 2007 Module 2

PowerPoint Presentation to Accompany GO! All In One. Chapter 13

Microsoft Access XP (2002) Queries

STIDistrict Query (Basic)

SECTION 4 USING QUERIES. What will I learn in this section?

Name: Class: Date: Access Module 2

Microsoft Access 2010 Select Queries

Chapter 4. Microsoft Excel

Excel. Spreadsheet functions

Introduction to PeopleSoft Query. The University of British Columbia

SPREADSHEET (Excel 2007)

Skills Exam Objective Objective Number. Creating crosstab queries Create a crosstab query

Microsoft Access 2016 Intro to Select Queries

Microsoft Office 2016 Mail Merge

Unit 12. Electronic Spreadsheets - Microsoft Excel. Desired Outcomes

Information from Your

Introduction to Microsoft Access 2016

Using Parameter Queries

Access Module 2: Building and Using Queries

Access Groups. Collect and Store. Text Currency Date/Time. Tables Fields Data Type. You Your Friend Your Parent. Unique information

A Tutorial for Excel 2002 for Windows

Chapter 4: Single Table Form Lab

ICDL & OOo BASE. Module Five. Databases

Veco User Guides. Grids, Views, and Grid Reports

Excel Tables and Pivot Tables

CHAPTER 6 SUMMARY. Objective 1: Identify Good Database Design

Shelly Cashman Series Microsoft Office 365 and Access 2016 Introductory 1st Edition Pratt TEST BANK

MS Access Let s begin by looking at the toolbar and menu of Access.

Access Groups. Collect and Store. Text Currency Date/Time. Tables Fields Data Type. You Your Friend Your Parent. Unique information

REPORT WRITER MANUAL (Version 10)

SOFTWARE SKILLS BUILDERS

M I C R O S O F T A C C E S S : P A R T 2 G E T T I N G I N F O R M A T I O N O U T O F Y O U R D A T A

Microsoft Access Basics

Microsoft Access 2016

Getting started with Ms Access Getting Started. Primary Key Composite Key Foreign Key

Microsoft Office Access 2013: Part 01. Lesson 04 - Creating Advanced Queries

Microsoft Access 2016

GOOGLE SHEETS MANAGING YOUR DATA

THE EXCEL ENVIRONMENT... 1 EDITING...

Microsoft Word 2010 Introduction to Mail Merge

Microsoft Access 2003 Edition for ECDL Syllabus 4.5 (UK only)

Microsoft Access 2003 Quick Tutorial

Introduction to MS Access queries

CartêGraph Training Navigator

Basic tasks in Excel 2013

Princeton University Exercise Workbook Training Developed by Elisabetta Zodeiko, Princeton University

Access 2007: Advanced Instructor s Edition

EXCEL BASICS: MICROSOFT OFFICE 2010

Table of Contents COURSE OVERVIEW... 5

Links to Activities ACTIVITY 4.1. Links to Activities Links to Activities

Access Review. 4. Save the table by clicking the Save icon in the Quick Access Toolbar or by pulling

Advanced Queries: Moving Beyond the Select Query Instructor: Edwin V. Bonilla

Introduction to Microsoft Excel 2010

-Using Excel- *The columns are marked by letters, the rows by numbers. For example, A1 designates row A, column 1.

Spreadsheet definition: Starting a New Excel Worksheet: Navigating Through an Excel Worksheet

Data. Selecting Data. Sorting Data

Microsoft Access 2007 Level 3

Using Reports. Access 2013 Unit D. Property of Cengage Learning. Unit Objectives. Files You Will Need

SUM - This says to add together cells F28 through F35. Notice that it will show your result is

PM4 + Partners Knowledge Articles

ITEC 101 LAB 9 USING A DATABASE: Tables and Queries

Microsoft Excel 2010 Handout

The American University in Cairo. Academic Computing Services. Excel prepared by. Maha Amer

Tutorial 3 Maintaining and Querying a Database. Finding Data in a Table. Updating a Database

Pivot Tables, Lookup Tables and Scenarios

Functions in Excel. Structure of a function: Basic Mathematical Functions. Arithmetic operators: Comparison Operators:

EXCEL Using Excel for Data Query & Management. Information Technology. MS Office Excel 2007 Users Guide. IT Training & Development

Top Producer 7i Tips & Tricks Volume 1

Introduction to Microsoft Excel

Row 1 is called the header row which contains all the field names. Records start in row 2.

When you pass Exam : Access 2010, you complete the requirements for the Microsoft Office Specialist (MOS) - Access 2010 certification.

Section 1 Creating Mail Merge Files

SAS Studio: A New Way to Program in SAS

Welcome to Cole On-line Help system!

Product: ODTView. Subject: Basic Overview of Scheduler Tab. Version: December 6, Distribution: Customer

Transcription:

Access - Introduction to Queries Part of managing a database involves asking questions about the data. A query is an Access object that you can use to ask the question(s). The answer is contained in the fields of one or more tables or queries. You can use queries to sort records, select records, exclude fields, and calculate values to name a few questions you may have. When you create a query, the Query Tools appear. The Design tab can be utilized to work with your query. You can show results of the query, change the query type, change the setup of the query and show or hide other pieces. Select Query select or summarize specific record information. Parameter a variable used to prompt the user for specific parameters. Crosstab used to compare the relationship between two fields. Union see results of more than one similar query as a combined query. Action Query using one of these queries, you can perform an action on existing data. Before running this type of query, start with a select query to make sure the correct data is chosen. Make-Table results are placed into a new table. Append results are added to an existing table. Update modify data in a table. Delete delete data from a table. Access - Introduction to Queries Page 1

Using Sort or Filter Sorts/Filters vs Queries Utilizing a sort or filter is faster than setting up a query. The results of a sort or filter are not saved or are only temporarily saved but queries can be saved permanently and executed again. A sort or filter is used only on tables or forms which are open but queries can be executed on multiple tables and other queries which are not open. Use Queries Sorts You want to display a subset of records from one or more tables without opening the tables. You want to query more than one table or add tables later to the question. You want to exclude certain fields from displaying. You want to perform calculations on fields. You want to use the query in the future. Use the sort icon buttons from the Sort & Filter group of your Home tab to sort your Datasheet. When Access sorts numbers, you have to pay attention to how your data style was set. What you think was set to the number type, may have been set to text instead. Access does sort numbers differently than it sorts text as displayed in the following table. Original Sort as Text Sort as Number 1 1 1 1234 11 2 24 12 3 3 1234 4 11 2 11 22 22 12 12 24 22 4 3 24 2 4 1234 Page 2 Access - Introduction to Queries

Filters Use your Right Mouse Button to apply Filters. Filters allow you to view only the information you selected or view all information excluding your selection. Example 1 - Let's suppose you want to view only zip code 50310. In the Zip code field, find a record with the zip code 50310, click with your right mouse button and select, Equals 50310. Example 2 - Now you want to see all the records that do not have the zip code 50310. Same procedure as above, except now you want to select, Does Not Equal 50310. To view all records again use your right mouse button and select Clear filter from Zipcode. Advanced Sort/Filter 1. Make sure to clear all sorts and filters before continuing. 2. Click the Advanced button from the Sort & Filter group on the Home tab. 3. Choose Advanced Filter/Sort. 4. Drag the appropriate fields to the design grid. 5. Select Ascending, Descending or not sorted from the Sort row. 6. Type in any filter criteria. 7. Click the Toggle Filter button. To sort or filter more than one column at a time, the columns have to be lined up left to right in the order you want to apply the sort or filter. To save the sort/filter, click the save icon from the Quick Access Toolbar. Type in a name for the query. Find Another feature that can be used on a table is the find function. Use the icon from the Find group of the Home tab or Ctrl +F to find a specific item. You can even replace an item you find using this feature. Access - Introduction to Queries Page 3

Creating a Query using the Query Wizard The wizard walks you through creating a query step-by-step. You can select fields from tables, but you cannot add criteria to a field in the wizard. You will use the Design View after the query is created to add specific criteria. 1. Click the Create tab. 2. Click the Query Wizard icon from the Other group. 3. Select the type of query to use. 4. Click the OK button. 5. Select the table or query from the drop-down list. 6. Select the field you wish to have in the new query. 7. Click the > button. 8. Continue until all the fields you want are selected. 9. Click the Next button. 10. Enter in a title for the query. 11. Choose either Open the query to view information or Modify the query design. 12. Click the Finish button. After you click Finish, the query will display the results on your monitor. Your new query will be added to your database under the Queries object. You can run your new query any time you need an updated answer to the question. You can open the query to modify the question or just run the query to find the answer. If you have numeric fields, date fields, etc. the Wizard will have additional screens to prompt you for information. It will ask you if you want a detail or summary query. It even allows you to select how you want to display the summary of data. Page 4 Access - Introduction to Queries

Creating a Query in Design View The wizard works great for some queries; however, it is sometimes quicker to start your query in the design mode. You can select multiple tables, queries, the fields, and then enter your specific criteria. In the Design View you can create temporary relationships between tables by creating joins in the view. The join you create in the query only applies to the query you are creating. 1. Click the Create tab. 2. Click the Query Design icon in the Other group. 3. Choose the Tables, Queries, or Both tab. 4. Select the table or query of choice. 5. Click the Add button. 6. When all of the tables or queries are added, click the Close button. 7. Click and drag specific fields to the design grid. 8. When you have all the fields added you want in the query, click the View or Run button from the Results group. The query is automatically created as a select query as this is the most requested query in a database. The table or query will appear in the top portion of the Design View displaying all the fields for each table or query. The bottom part of the Design View is the design grid. This is where the fields we want to question will be displayed. To add the fields to the design grid you can, double click the field name, press and hold the field name and drag it to an empty column or click on the first empty column and select from the drop-down list. Both the View and Run buttons will give the same result in a select query but be careful when running other types of queries. Access - Introduction to Queries Page 5

Field each column. Table name of the table. Sort ascending or descending. Show checked will show in results. Criteria similar to validation, what you are looking for. Total if using a calculation. Update To will show for an update query. Crosstab will show for a crosstab query. Delete will show for a delete query. * - select all field from the table or query. The properties applied to a field are inherited from the table properties. Use the property sheet to override. To move a column, highlight it and click and drag it. Note: If you move the column in Datasheet View, it may not update in Design View and the opposite is also true. Sorting your Fields in a Query 1. In the Design grid, click on the Sort cell for the field you want to sort. 2. Click on the drop-down arrow and select either Ascending or Descending. 3. Click on the View button to view your query with the new sort option. To remove the sort option, select not sorted from the drop-down list. You can select more than one field to sort by, remember the sort order moves left to right. Page 6 Access - Introduction to Queries

Adding Criteria By entering criteria into your query you can answer a more detailed question. Access refers to the criteria you enter as an expression. 1. Place the cursor in the Criteria cell of the field you want to apply a condition to. 2. Enter the criteria you want to apply here are some examples. Text DPM for Student Program. Quotes around items with spaces CA or NC Date 1/15/2001 for a specific date. Surround dates with # sign #1/15/2001#. Numeric Comparisons - <75 for an exam score of less than 75. 3. Click the View button to verify the criteria you applied to the query answers your question. Understanding and Working with Expressions Expressions contain operators, symbols, field names and other Access elements that result in a single outcome such as totaling a payments field or finding all students who received a 74 or below (<75) on an exam. Wildcards You can use wildcard characters to broaden the numerous questions you may have in your query. Wildcard characters allow you to search for patterns of alphanumeric characters, such as all names that begin with a specific letter. There are three wildcard characters to specify an expression: The asterisk * represents a series of characters. The question mark? represents a single character. The # mark represents a number. Examples of wildcard expressions: J* Selects all records that begin with J. 12/*/01 Selects all records dated December, 2001. 4?000 Selects all records beginning with 40000 and ending 49000. *books Selects all records that concludes with books. 4### Selects all records that start with 4 and have three numbers after it. Access - Introduction to Queries Page 7

AND, OR, BETWEEN, IN To enhance your query, you may specify multiple criteria. The AND operator combines the criteria to say the record must meet both criteria. Your criteria is placed on the same Criteria row for the AND operator to work. The OR operator provides you flexibility. The record must meet one of the criteria. When using the OR operator, the first criteria choice is placed on the Criteria line and the second or multiple criteria is placed on the OR lines. The BETWEEN operator provides you with the ability to ask for data that fits between a set of criteria. For example: BETWEEN 10 and 20 which is the same as >=10 and <=20. The IN operator allows you to specify the particular results. They have to be one of the chosen items. For example: IN( CA, NC, TN ). Calculated Fields You use expressions in queries to create calculated fields. Calculated fields appear as separate fields in the query. In essence, you are creating a new field when you create a calculated field. A calculated field can: Perform a mathematical calculation on values in one or more fields. Combine text from two or more fields. 1. Click in the field row of an empty column. 2. Type the name you want to give the calculated field and end it with a colon, such as Total: 3. After your new field name, enter the name of the field that contains the values which you want to perform the calculation on. The field name must be enclosed in square brackets. If you want to total your Payments field, enter Total: [Payments]. 4. Click on the Totals icon. This tells the query to sum this field. 5. Make any additional changes you wish. 6. Click the View button to verify your query results. Page 8 Access - Introduction to Queries

Combining Text This is used quite often to combine First & Last Name fields, City, State, Zip fields, etc. The fields are still separate in the table for sorting purposes, but can be combined to look better on a report. You must use the ampersand (&) operator in your calculation. CSZ: ([City] & ", " & [Region] & " " & [PostalCode]) Access would display: Des Moines, IA 50312 FullName: ([LastName] &, & &[FirstName] & & [MiddleName] Access would display: Taylor, Donna Sue If you did not use the calculation your display on the report could look like this: Parameters Des Moines IA 50312 Use parameters to create a new field. When the query is executed, it will ask for specific parameters. This information is entered in the criteria cell of the Design View. For example: If you want to ask for a specific date [Start Date]. Editing your Query You can insert additional fields, re-position fields and delete fields in an existing query. After reviewing your query, you may need to add another field to help answer the question. To insert a field, use the same steps as you do when creating a new query, you can double click the field name to add a field to the end of the query or you can drag the field into the design grid exactly where you want to place the field. You may find it helpful to change the order of your fields, especially for sort features. To reposition fields, move your mouse pointer directly above the gray area until it changes to a black down arrow and click on the column. Once the column is selected, move your mouse to the edge of the column, press and hold and drag the column to the new position on the design grid. Sometimes you need to delete a field from the query. To delete a field, select the field column as described above, and then press the Delete key. You can delete all fields on the design grid by selecting Edit from the menu and clicking Clear Grid. Access - Introduction to Queries Page 9

Notes: Page 10 Access - Introduction to Queries