Database Applications Microsoft Access



Similar documents
Tutorial 3. Maintaining and Querying a Database

Microsoft Office 2010

Tutorial 3 Maintaining and Querying a Database

Access Tutorial 3 Maintaining and Querying a Database. Microsoft Office 2013 Enhanced

Microsoft Access 3: Understanding and Creating Queries

Database Applications Microsoft Access

Access Queries (Office 2003)

Creating QBE Queries in Microsoft SQL Server

Click to create a query in Design View. and click the Query Design button in the Queries group to create a new table in Design View.

Joins Joins dictate how two tables or queries relate to each other. Click on the join line with the right mouse button to access the Join Properties.

Sample- for evaluation only. Introductory Access. TeachUcomp, Inc. A Presentation of TeachUcomp Incorporated. Copyright TeachUcomp, Inc.

Fig. 1 Suitable data for a Crosstab Query.

Ad Hoc Advanced Table of Contents

Access 2010: Creating Queries Table of Contents INTRODUCTION TO QUERIES... 2 QUERY JOINS... 2 INNER JOINS... 3 OUTER JOINS...

Working with Access Tables A Continuation

Unit 10: Microsoft Access Queries

Introduction to Microsoft Access 2007

MS Access: Advanced Tables and Queries. Lesson Notes Author: Pamela Schmidt

A Basic introduction to Microsoft Access

In This Issue: Excel Sorting with Text and Numbers

Building Queries in Microsoft Access 2007

Lab 9 Access PreLab Copy the prelab folder, Lab09 PreLab9_Access_intro

Introduction to Microsoft Access 2013

Querying a Database Using the Select Query Window

Excel Database Management Microsoft Excel 2003

MICROSOFT ACCESS 2003 TUTORIAL

Chapter 5. Microsoft Access

Introduction to Microsoft Access 2010

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

2012 Teklynx Newco SAS, All rights reserved.

Using an Access Database

Microsoft Excel 2010 Part 3: Advanced Excel

Tommy B. Harrington 104 Azalea Drive Greenville, NC

4. The Third Stage In Designing A Database Is When We Analyze Our Tables More Closely And Create A Between Tables

Lesson 07: MS ACCESS - Handout. Introduction to database (30 mins)

MS Access Lab 2. Topic: Tables

Microsoft Access 2007 Advanced Queries

Access Queries

Microsoft Access 2010 Part 1: Introduction to Access

Crystal Reports Payroll Exercise

Computer Training Centre University College Cork. Excel 2013 Pivot Tables

Access 2003 Introduction to Queries

Access Part 2 - Design

Use Find & Replace Commands under Home tab to search and replace data.

A database is a collection of data organised in a manner that allows access, retrieval, and use of that data.

Lab Manual. Databases. Microsoft Access. Peeking into Computer Science Access Lab manual

IS 312, Information Systems for Business Database Project in Access

Queries Requiring Two Tables

Creating a Database in Access

European Computer Driving Licence

Introduction to Microsoft Access 2003

Getting Started with Access 2007

REP200 Using Query Manager to Create Ad Hoc Queries

C omputer D riving L icence

Objectives. Understand databases Create a database Create a table in Datasheet view Create a table in Design view

Sample- for evaluation purposes only. Advanced Crystal Reports. TeachUcomp, Inc.

How To Understand The Basic Concepts Of A Database And Data Science

Microsoft Access Creating Filters and Tables

Microsoft Access 2010

IRA Pivot Table Review and Using Analyze to Modify Reports. For help,

Top ClientBase Windows Queries

Microsoft Access 2010: Basics & Database Fundamentals

Netmail Search for Outlook 2010

Query 4. Lesson Objectives 4. Review 5. Smart Query 5. Create a Smart Query 6. Create a Smart Query Definition from an Ad-hoc Query 9

Microsoft Excel 2007 Consolidate Data & Analyze with Pivot Table Windows XP

COURSE DESCRIPTION. Queries in Microsoft Access. This course is designed for users with a to create queries in Microsoft Access.

Microsoft Access 2010 Overview of Basics

IN THIS PROJECT, YOU LEARN HOW TO

The Center for Teaching, Learning, & Technology

Microsoft Office 2010

Check out our website!

MICROSOFT ACCESS STEP BY STEP GUIDE

Computer Science 125. Microsoft Access Project

MS Excel. Handout: Level 2. elearning Department. Copyright 2016 CMS e-learning Department. All Rights Reserved. Page 1 of 11

SPSS: Getting Started. For Windows

Using Microsoft Access

PeopleSoft Query Training

Microsoft Excel 2007 Mini Skills Overview of Tables

Introduction to Microsoft Jet SQL

Microsoft Access Basics

Creating and Using Databases with Microsoft Access

Using AND in a Query: Step 1: Open Query Design

Creating a Database using Access 2007

Excel 2010: Create your first spreadsheet

Using SQL Queries in Crystal Reports

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

How To Use Excel With A Calculator

2009 Braton Groupe sarl, All rights reserved.

Elisabetta Zodeiko 2/25/2012

Monthly Payroll to Finance Reconciliation Report: Access and Instructions

ADP Workforce Now V3.0

What is a database? The parts of an Access database

Access Using Access

Lab 2: MS ACCESS Tables

Using Delphi Data with Excel and Access

Excel Working with Data Lists

Exploring Microsoft Office Access Chapter 2: Relational Databases and Multi-Table Queries

MICROSOFT OFFICE ACCESS NEW FEATURES

Access 2010 Intermediate Skills

Transcription:

Database Applications Microsoft Access Lesson 4 Working with Queries Difference Between Queries and Filters Filters are temporary Filters are placed on data in a single table Queries are saved as individual objects in the database Queries can select data from multiple tables 36 Slides in Presentation 4 Lesson 4 Tutorial 3 For Lesson 4, you will work through Tutorial 3 in your textbook. The tutorial may expose you to more information than is identified in the course competencies. This presentation focuses on the skills necessary to achieve the course competencies as outlined in your syllabus. 2 Types of Queries The following is a list of various types of queries that can be created in Access: Simple Select Query-retrieves and displays data in specified fields. Select Query with Criteria-retrieves and displays requested fields for records which meet specified criteria. Crosstab Query-summarizes information by rows and columns. Parameter Query-Displays a dialog box asking the user for criteria for the query. Delete Query-removes a group of records matching specified criteria. Find Duplicates Query-retrieves records that are entered in a database multiple times. Find Unmatched Query-finds all records in a table or query that have no matching records in a related table. Append Query-adds records from an existing table to the end of another table. Top Values Query-limits the number of responses a query returns. Update Query-changes specified fields fro many records at one time. 5 Queries One of the most valuable tools in Access is the Query. Queries are Access objects used to Retrieve specified information from tables. Generate information to be used in preparing reports. Perform calculations on data found in fields of underlying tables. 3 Query Operations Queries can not only be used to retrieve data by specifying fields and criteria, but can be used to generate information. Queries can contain calculated fields that are not found in the underlying tables that the query is based upon. Queries can contain expressions to perform calculations to generate new information. Queries can contain Total fields to group by fields and summarize statistical data. 6 1

Designing Queries One of the most important skills in query design is critical thinking. Creating select queries can be very simple. Designing queries with multiple criteria requires logical thought and precise definition. Follow this checklist when creating queries: Thoughtfully define the results you want. List the fields you want returned in the query results. Define and apply the criteria necessary to return the desired results. Choose the appropriate query type to achieve the desired results. Run the query to see that the query results match your desired outcome. 7 Adjust the query design if necessary. Simple Design Select GridQueries Execute the following steps to complete the query. Double-click the table or tables containing fields desired for the query. (A multitable query is a query based on more than one table.) Double-click each field you wish to display in the query results in the order you want the fields displayed in the query results. 10 Simple Select Queries A Simple Select Query is used to retrieve only specified fields from an underlying table or tables. Queries can be created using the Query Wizard or queries can be created in Design View. To create a simple select query in Design View Click Query Design in the Queries Group of the Create Tab Add the table/s containing the fields you want in the query results Simple Double-click Select each field Queries to add it to the query design grid 8 Design Grid Simple Select Query The following design grid shows three fields out of seven selected from the Employees table. Query Criteria Remember that simple select queries are used to select and isolate specified fields from a table or tables. As the name implies, these queries are very simple to design. 11 Once you have chosen to Create a query, the Query Design grid displays. You will define your query by selecting fields and placing them on the design grid. 9 Criteria are limiting factors placed on data. Criteria can be added to the query design to limit the records selected for the query results. Criteria can be specific or you can use wild cards to select records with a certain string of characters. Criteria can also use logical operators such as AND, OR, and BETWEEN or comparison operators such as >, <, or = to identify requested records. 12 2

Using Character String Criteria To place criteria in a query, type the requirement in the Criteria row under the appropriate field. The example below shows that the criteria of Nashville must be met in the City field for a record to be selected. Criteria involving text is known as a character string. Note that text criteria is enclosed in quotes. This is an example of an exact match condition. 13 Using Comparison Operators in Criteria Between Operator The Between operator limits data selections within a specified range. The Between operator must always be paired with the And operator. When you might use the Between operator: To find data within a date range Between 1/1/2012 And 12/31/2012 To find data within a certain numerical range, for instance age Between 18 And 35 To find data within a specified alphabetical range- Between Abe And Ellen Between a* And l* (when combined with a wild card) 16 Using Logical Operators in Criteria AND and OR are examples of logical operators that can be used in queries. When the AND operator is used, all criteria must be met. When the OR operator is used, any of the specified criteria may be met. The example below shows that the criteria of Nashville OR Memphis must be met in the City field for a record to be selected. Comparison Operators For additional comparison operators along with examples, see page AC 142 of your Access text. 14 17 Using Comparison Operators in Criteria > greater than < less than >= greater than or equal to <= less than or equal to <> not equal to Comparison Operators Query Results Query results are displayed in a datasheet. To see the results of your query, click the run button. Use comparison operators to compare values and dates. When evaluating dates, a date earlier than the specified date is less than while a date later than the specified date is greater than. 15 18 3

Sorting Data Query results can be sorted to provide a more useful arrangement of data. Data can be sorted in two orders: ascending ordered alphabetically from A to Z or numerically from 1 to 100 descending - ordered alphabetically from Z to A or numerically from 100 to 1 Performing Calculations in Queries Mathematical Operators Below are the four most frequently used mathematical operators: Addition + Subtraction - Multiplication * Division / Sorting Data 19 Performing Calculations in Queries 22 An Example Your boss is considering increasing the price of all products Query results can be sorted in datasheet view, however, the sort options in this view are somewhat limited and temporary. For best results, define sort criteria in the Query Design Grid. Data may be sorted on multiple fields. Each field on which a sort is performed is called a sort field or sort key. The sort field that defines the main order of the sort is the primary sort field. All other sort fields are secondary sort fields. Sort order is determined by the order of the sort fields. Performing Calculations in Queries Queries can be used to generate data based on calculations performed in the queries. Expressions (formulas) are entered in the query design grid to generate data. Expressions generally include field references, mathematical operators, and constants (stated values). 20 by 5%. He has asked that you provided data on what the new product prices will be. You will design a query to calculate the new prices. The field Price contains the current product price. The query will determine the new prices based on the following expression entered in a blank field in the query design grid: [Price]*1.05 In this expression, the field Price is distinguished by placing it in brackets. The mathematical operator for multiplication is entered next, followed by the constant value of 105% (converted to a decimal). Using 105% in the expression will generate the total new price. Using only 5% in the expression would calculate amount of price increase but not the new Naming Calculated Fields 23 price. Calculated fields in queries will be given the name Expr1 by default. To give a calculated field a more descriptive name, precede the expression with the field name. Differentiate between the field name and the expression with a colon (:). See the example below in which we assign the name for the increased price New Price. New Price: [Price]*1.05 21 24 4

Performing An Example Calculations in Queries The query containing the expression would appear as follows in Design View: The following results are generated from this query: Notice that the field name given to the calculated field appears as the column heading. To create this analysis, first enter the Query Design window. Select only the field you wish to analyze. If you wish to determine more than one statistic on the selected field, add the same field for each statistic you want to use. Turn on Aggregate Functions by clicking the Totals tool: The Totals field will now appear on your query design grid. The default value for the Totals field is Group By. If you click beside Group By, you will get a list of all the aggregate functions. Choose the appropriate function for your analysis. Using Aggregate Functions Statistical operations can be performed by using the aggregate function options in Access. Common aggregate function operations include 25 We will view an example assuming management wants to know the highest and average monthly fees. 28 Sum totals the specified field in a group of records (use with numeric fields only) Count returns the number of records in a group (use with any field) Average finds the average value in a group of records Maximum finds the largest value in a group of records Minimum finds the smallest value in a group of records In the Query Design grid, add the Monthly Fees field twice (add the field twice because you want to perform two analyses on this field highest and average.) Statistical analyses are often done on one field only. We will look at an example based on the following table. This table has four fields, but management would like an analysis of the Monthly Fee. 26 Now turn the Totals field on. Note the new row in the Query Design grid. 29 Recall that the default value for the Total field is Group By. 27 30 5

Click beside Group By and a drop-down arrow will appear. Click this arrow and select the aggregate function necessary to perform your analysis. In this example, we will choose Max (to determine the highest fee) and Avg (to determine the average fee). Creating Aggregate Grouped a By Statistical Functions Field Analysis with ausing The results of the query with a Group By field added are shown below: The results of this query may seem strange since it will be only one row as shown below but these are the correct results. Creating Aggregate Grouped a By Statistical Functions Multiple Fields Analysis Using an We previously discussed that statistical analyses are usually performed on one field only. Now let s assume that management wants to see the highest and average fees organized by city served. The only change to the query to accomplish this is to add the City field (from another table) and leave this field at the default Group By setting as shown. 31 32 Management can now see the highest fee and the average fee for each city served by this company. End of Lesson Work through Tutorial 3 on pages AC 116 170 in your Access textbook. (Recall that the tutorial may expose you to more information than is identified in the course competencies). Complete the assigned exercises. (Exercise objectives will be limited to course competencies.) 34 35 33 6