SlideShare a Scribd company logo
Succeeding in Business with Microsoft Access 2013
Analyzing Data For Effective
Decision Making
Succeeding in Business with Microsoft Access 2013
Chapter Introduction
• Filter data in a Microsoft Office Access 2013
database
– Retrieve and examine only the records you need
– Sort data to rearrange records in a specified order
• Create complex queries
• Explore advanced queries
• Explore queries written in Structured Query
Language
2
Succeeding in Business with Microsoft Access 2013
Tools Covered In This Chapter
• Action queries (update, append, delete, crosstab,
and make-table)
• Aggregate functions (Avg, Max, Min, Sum)
• Calculated field
• Comparison and logical operators
• Crosstab query
• Filter by Form and Filter by Selection
• Find duplicates query
• Find unmatched records query
3
Succeeding in Business with Microsoft Access 2013
Tools Covered In This Chapter (cont’d.)
• Immediate IF (IIF) function
• Parameter query
• Design View
• Select query
• Simple Query Wizard
• SQL commands
• Top Values query
• Wildcard character
4
Succeeding in Business with Microsoft Access 2013
Level 1 Objectives: Organizing and Retrieving
Information from a Database
• Filter and sort data to make it more
meaningful
• Create simple queries to answer business
questions
• Develop queries using comparison criteria and
wildcards
• Verify and print query results
5
Succeeding in Business with Microsoft Access 2013
Filtering and Sorting Data
• Filter
– Restricts data in single table to create temporary
subset of records
– See only certain records in table based on
specified criteria
• Sorting records
– Organizing in particular order or sequence
– Sort records regardless of whether table filtered
6
Succeeding in Business with Microsoft Access 2013
Filtering by Selection
• Tools
– Filter by Selection
• Select particular field in datasheet
• Display only data that matches contents of field
• Specify only one criterion for filter
– Filter by Form
7
Succeeding in Business with Microsoft Access 2013 8
Succeeding in Business with Microsoft Access 2013
Filtering by Form
• Specify two or more criteria
• Filter for comparative data
– Use comparison operators
• AND criteria
– Selects records that contain all specified values
• OR criteria
– Selects records that contain any of specified
values
9
Succeeding in Business with Microsoft Access 2013
Sorting Data to Increase Information Content
• Lets you view the information in a variety of ways
• Access sorts records based on primary key values
– Use sorting to change order
• To sort
– Select sort field
• Sort on multiple fields
– Move fields in Datasheet view so that they are
adjacent
10
Succeeding in Business with Microsoft Access 2013
Sorting Data To Increase Information Content
(cont’d.)
• How Access sorts different types of data
11
Succeeding in Business with Microsoft Access 2013
Filtering Using the Filter Arrow
12
Succeeding in Business with Microsoft Access 2013
Using Queries to Answer
Business Questions
• Query
– Database object
– Stores criteria for selecting records from one or
more tables based
– Save query
• Use it again
– More powerful than filter
• Display only some fields in table
• Create fields that perform calculations
13
Succeeding in Business with Microsoft Access 2013
Using Queries to Answer
Business Questions (cont’d.)
• Capabilities of Access queries:
– Display selected fields and records from table
– Sort records on one or multiple fields
– Perform calculations
– Generate data for forms, reports, and other queries
– Update data in database
– Find and display data from two or more tables
– Create new tables
– Delete records in table based on one or more criteria
14
Succeeding in Business with Microsoft Access 2013
Using Queries to Answer
Business Questions (cont’d.)
• Select query
– Ask question based on one or more tables in
database
– Result displayed in datasheet
• Called recordset
15
Succeeding in Business with Microsoft Access 2013
Using the Simple Query Wizard
to Create a Query
• Simple query wizard
– Presents list of tables and queries in database
• And fields that they contain
– Select fields from one or more tables
– Wizard creates and displays results
16
Succeeding in Business with Microsoft Access 2013
Including Summary Statistics in a Query for
Data Analysis
• Summary query
– Groups records
– Calculate sum, average, minimum, or maximum
value in each selected field
– Count records in table or query
• Click Summary Options button
17
Succeeding in Business with Microsoft Access 2013 18
Figure 3.7: Creating a summary query with the Simple Query Wizard
Succeeding in Business with Microsoft Access 2013
Creating a Query in Design View
• Select Query window in Design view has two
sections
– Area for field lists at top of window
– Design grid below it
• Add tables for query to top part of window
– Appear as field lists
• Query by example (QBE)
– Typing search value as a criterion
19
Succeeding in Business with Microsoft Access 2013 20
Succeeding in Business with Microsoft Access 2013
Creating Queries with
Multiple Criteria
• Most queries involve more than one criterion
• Represent AND criteria
– Enter conditions in same criteria row in query
design grid
• Specify OR criteria
– Use “or” row of query design grid
21
Succeeding in Business with Microsoft Access 2013 22
Figure 3.10: Setting criteria for the query in Design view
Succeeding in Business with Microsoft Access 2013
Specifying Sort Order in Queries
• Query results appear in same order as data
from underlying tables
– Unless specify sort order when designing query
• Sort order determined from left to right
23
Succeeding in Business with Microsoft Access 2013
Running a Query
• Click Run button in the Results group
– Access displays datasheet of records
• Save query
– Save only design
– Not values from tables displayed in results
24
Succeeding in Business with Microsoft Access 2013
Enhancing Query Criteria to Improve Data
Analysis
• Expand criteria by using
– Wildcards
– Comparison operators
25
Succeeding in Business with Microsoft Access 2013
Using Wildcards for Inexact
Query Matches
• Wildcard character
– Placeholder
– Stands for one or more characters
• Comment fields
– Use same keywords throughout comments
– Easily retrieve records later
– Use wildcards when specifying keyword as a query
criterion
• To select records that contain characters before and after
keyword
26
Succeeding in Business with Microsoft Access 2013 27
Succeeding in Business with Microsoft Access 2013
Using Wildcards for Inexact Query Matches
(cont’d.)
• Access inserts
– Word “LIKE” for criteria with wildcards quotation
marks around text
• LIKE “*Spanish*”
– Pound signs around dates
• #12/*/2013#
28
Succeeding in Business with Microsoft Access 2013
Using Comparison Operators to Refine Query
Criteria
• Comparison operators
– Compare value in field with range of values in
criterion
• Clear the design grid to create or modify a
query
– Start with same field list but blank grid
29
Succeeding in Business with Microsoft Access 2013 30
Succeeding in Business with Microsoft Access 2013
Verifying and Printing
Query Results
• Verify query results before
– Distributing query to others
– Using it as basis for decisions
• Use business knowledge
– Determine whether results adequately answer
question
• Print query datasheet
31
Succeeding in Business with Microsoft Access 2013
Modifying Query Datasheets
• Improve appearance of query or table
datasheet
• Resize column widths in any datasheet
– Double-click line between field names to resize
columns to best fit
32
Succeeding in Business with Microsoft Access 2013 33
Succeeding in Business with Microsoft Access 2013
Level 1 Summary
• Use filtering and sorting to change data
display
• Develop queries using
– Simple query wizard
– Design view
• Use comparison operators and wildcards to
make queries more flexible
• Verify query results using business knowledge
34
Succeeding in Business with Microsoft Access 2013
Level 2 Objectives:
Creating More Complex Queries
• Design queries that compare data from more
than one table
• Refine table relationships by specifying the
join type
• Perform calculations in queries
• Customize queries and their results
35
Succeeding in Business with Microsoft Access 2013 36
Succeeding in Business with Microsoft Access 2013
Using Queries to Find Duplicate Records
• Duplicates Query Wizard
– Searches for duplicate values in fields
– Improves business operations
– Designed to identify records that contain same
information in particular field
37
Succeeding in Business with Microsoft Access 2013
Using Queries to Find Unmatched Records
• Find Unmatched Query Wizard
– Compares records in two specified tables or
recordsets
– Finds all records in one table or query that have
no related records in second table or query
– Requires that two tables being compared have
common field
38
Succeeding in Business with Microsoft Access 2013
Limiting the Records in the Query Results
• Limiting results to only a few records often
aids analysis
• Top and Bottom Values
– Set a sort order for the field
– Descending to display the records with the highest
values
– Ascending to display the records with the smallest
values
39
Succeeding in Business with Microsoft Access 2013 40
Succeeding in Business with Microsoft Access 2013
Using Parameter Values in Queries
• Parameter values
– Phrase usually in form of a question or instruction
– Enclosed in square brackets
– Serves as prompt to user to enter value
– Example
• [Enter a job ID:]
41
Succeeding in Business with Microsoft Access 2013 42
Succeeding in Business with Microsoft Access 2013
Analyzing Data from More than One Table
• Data from more than one table required to
answer question
– Combine records from two or more tables
– Display only information needed
• Work in Design View to specify criteria for
selecting records from multiple tables
• Lines between tables link primary key to foreign
key field
– Primary key designated with 1
– Foreign key designated with ∞
43
Succeeding in Business with Microsoft Access 2013
Analyzing Data from More than One Table
(cont’d.)
• Join tables
– Linking of tables using primary and foreign keys
– Established relationship
– Or
• Each table shares field with same or compatible data type
• One join field primary key
• If tables do not include fields that can be joined
– Add one or more extra tables or queries
– Link tables that contain the data
44
Succeeding in Business with Microsoft Access 2013
Analyzing Data from More than One Table
(cont’d.)
• Use queries as source of underlying data for
another query in place of one or more tables
• Create queries based on more than one object
– Should not use any table or query that does not
have common field with at least one of the other
tables or queries
– Otherwise Access displays every combination of
records between two tables
45
Succeeding in Business with Microsoft Access 2013
Refining Relationships with Appropriate Join
Types
• Inner join
– Displays all records in one table that have
corresponding values in common field in another
table
– Records must match before being displayed in
query results
• Outer join
– Displays all records of one table
• Regardless of whether corresponding record is stored in
related table
46
Succeeding in Business with Microsoft Access 2013 47
Figure 3.34: Inner join
Succeeding in Business with Microsoft Access 2013 48
Succeeding in Business with Microsoft Access 2013 49
Figure 3.36: Right outer join
Succeeding in Business with Microsoft Access 2013
Refining Relationships with Appropriate Join
Types (cont’d.)
• Outer join types
– Left
– Right
• Use Join Properties dialog box
– To change join type
– By default, tables are related using inner joins
– Options for outer joins
50
Succeeding in Business with Microsoft Access 2013
Using Logical Operators
to Specify Multiple Conditions
• Logical operators
– Test values that can only be true or false
• Place conditions in separate fields in same
criteria row of design grid
– All conditions in row must be met to select record
• NOT logical operator
– Excludes values that don’t meet criterion
51
Succeeding in Business with Microsoft Access 2013 52
Succeeding in Business with Microsoft Access 2013
Performing Calculations with Queries
• Any information derived from fields in table or
query should be calculated in query
– Rather than included as data in table
• Calculation types
– Predefined
• Compute amounts for groups of records or for all records
combined in query
– Custom
• Perform numeric date and text computations on each record
• Using data from one or more fields
53
Succeeding in Business with Microsoft Access 2013
Calculating Statistical Information
• Aggregate functions
– Mathematic and statistical operations
– Apply to records that meet query’s selection
criteria
54
Succeeding in Business with Microsoft Access 2013 55
Succeeding in Business with Microsoft Access 2013 56
Figure 3.43: Using aggregate functions in a query
Succeeding in Business with Microsoft Access 2013
Creating Calculated Fields in a Query
• Expression
– Arithmetic formula for calculation
– Use standard arithmetic operators
– Use parenthesis for complex expressions
• Calculated field
– Add to query design grid
– Type expression
• Expression Builder
– Build complex expressions
57
Succeeding in Business with Microsoft Access 2013
Creating Calculated Fields in a Query (cont’d.)
• Function
– Performs standard calculation
– Returns value
• Date()
– Provides today’s date
• Field properties
– Change format and number of decimal places for
calculated field
58
Succeeding in Business with Microsoft Access 2013 59
Succeeding in Business with Microsoft Access 2013
Concatenating in Queries
• Concatenation
– Combining contents of two or more fields
– Operator
• &
– Example
• Name [EmpFirst]& " " & [EmpLast]
60
Succeeding in Business with Microsoft Access 2013
Level 2 Summary
• Use queries to select from more than one table
• Join types
– Inner
– Right outer
– Left outer
• Calculated field types
– Predefined
– Custom
61
Succeeding in Business with Microsoft Access 2013
Level 3 Objectives: Exploring Advanced
Queries and Queries Written in Structured
Query Language
• Calculate and restructure data to improve
analysis
• Examine and create advanced types of queries
• Make decisions in a query using the
immediate IF (IIF) function
• Develop queries using SQL
62
Succeeding in Business with Microsoft Access 2013
Analyzing Query Calculations
• More advanced queries
– Crosstab query
• Most useful for preparing data for further analysis
– Action queries
• Change or move many records in one operation
– Four types of action queries:
• Append, update, delete, and make-table
63
Succeeding in Business with Microsoft Access 2013
Analyzing Query Calculations (cont’d.)
• Crosstab queries
– Special type of totals query
– Perform aggregate function calculations on values
of one database field
– Determine exactly how summary data appears in
results
– Calculate and restructure data
• Analyze it more easily
– Work especially well with time-series data
64
Succeeding in Business with Microsoft Access 2013
Creating a Crosstab Query
• To create:
– Use Design View
• Start with select query that includes numeric values or
summary calculations
– Use the Crosstab Query Wizard
• Guides you through the steps
• Shows samples of how the crosstab results will look
65
Succeeding in Business with Microsoft Access 2013 66
Succeeding in Business with Microsoft Access 2013
Modifying Data Using Queries
• Action queries
– Modify data in table
– Add records to or delete records from table
– Create new table
• Backup data before using action query
67
Succeeding in Business with Microsoft Access 2013 68
Succeeding in Business with Microsoft Access 2013 69
Succeeding in Business with Microsoft Access 2013
Archiving Data with Make-table Queries
• Make-table query
– Creates table from some or all of the fields and
records in existing table or query
– Access does not delete selected fields and records
from existing table
70
Succeeding in Business with Microsoft Access 2013
Adding Records to Tables with Append Queries
• Append query
– Select records from one or more tables by setting
criteria
– Add those records to end of another table
– Selected records also remain in original tables
– Table to which records added must already exist
– Can bring data from another source into database
71
Succeeding in Business with Microsoft Access 2013
Removing Records from Tables with Delete Queries
• Delete query
– Removes information from table
– Based on specified criteria
– All records meeting criteria permanently removed
• Create select query first
– Convert to delete query
• Cascading deletes
72
Succeeding in Business with Microsoft Access 2013
Updating Data with an Update Query
• Update query
– Changes values of data in one or more existing
tables
– Create select query first
• Change type to update query
73
Succeeding in Business with Microsoft Access 2013
Making Decisions in Queries
• IF statement
– Tests condition
– Takes one action if condition true
– Takes another action if condition false
• IIF function
– Make IF decision
– Format
• IIF(condition to test, what to do if true, what to do if
false)
74
Succeeding in Business with Microsoft Access 2013
Customizing Queries Using Structured Query
Language
• Access designed as database management
system (DBMS) for:
– Small businesses
– Or departments within large businesses
• Structured query language
– Common query language of most DBMSs
– Use to query/update/manage relational databases
• Create query in Design View
– Access translates entries and criteria into SQL
statements
75
Succeeding in Business with Microsoft Access 2013
Customizing Queries Using Structured
Query Language (cont’d.)
• View statements by switching from Design
view to SQL view
• SELECT statement defines:
– What data query should retrieve from database
– How it should present data
76
Succeeding in Business with Microsoft Access 2013
Exploring the Components
of an SQL Query
• Keywords
– Use to construct SQL statements
• Most developers place each statement on
separate line
– To make SQL code easy to read
77
Succeeding in Business with Microsoft Access 2013 78
Succeeding in Business with Microsoft Access 2013
Creating a Union Query Using SQL
• Union query
– Combine, or unite, the results from two or more
select queries
79
Succeeding in Business with Microsoft Access 2013
Level 3 Summary
• Crosstab and Action queries
• IFF function
• SQL
– Use SQL view to edit SQL directly
80
Succeeding in Business with Microsoft Access 2013
Chapter Summary
• Queries retrieve data from one or more tables
– Action queries update data
– Perform calculations
– Make decisions using IIF function
• SQL
– Used to interact with relational databases
– Use SQL view to view/edit SQL statements
generated by Access
81

More Related Content

PPTX
Ch01 CMPT110
PPTX
Ch02 cmpt110
PPTX
Ch04 cmpt110
PPTX
Ch06 cmpt110
PPTX
Ch07 cmpt110
PPTX
Ch05 cmpt110
PPTX
Understand Charts in Excel - Chapter.03
PPTX
Ch05 Access
 
Ch01 CMPT110
Ch02 cmpt110
Ch04 cmpt110
Ch06 cmpt110
Ch07 cmpt110
Ch05 cmpt110
Understand Charts in Excel - Chapter.03
Ch05 Access
 

What's hot (20)

PPTX
Ch02 Access
 
PPTX
Ch01 Access
 
PPTX
Ch06 Access
 
PPTX
Ch03 Access
 
PPTX
Access 2013 Unit A
PPTX
Dynamics AX 2009 Data Dictionary - Güven Şahin - 04.05.2013
PPTX
Access 2013 Unit B
PPT
Ax Presentation
PPTX
AX 2012: All About Lookups!
PDF
Budget entries import in Dynamics AX 2012
PPTX
What is bip_v2
PDF
Data Warehouse approaches with Dynamics AX
PPTX
Dynamics ax 2012 development overview
PDF
Microsoft MCSE 70-467 it exams dumps
PDF
Access 2010 Unit A PPT
PPTX
Optimizing MS Dynamics AX 2012 R3
PDF
Bi requirements checklist
PPT
Ms Access ppt
PPTX
Erp microsoft dynamic ppt
PPTX
Access lesson 04 Creating and Modifying Forms
Ch02 Access
 
Ch01 Access
 
Ch06 Access
 
Ch03 Access
 
Access 2013 Unit A
Dynamics AX 2009 Data Dictionary - Güven Şahin - 04.05.2013
Access 2013 Unit B
Ax Presentation
AX 2012: All About Lookups!
Budget entries import in Dynamics AX 2012
What is bip_v2
Data Warehouse approaches with Dynamics AX
Dynamics ax 2012 development overview
Microsoft MCSE 70-467 it exams dumps
Access 2010 Unit A PPT
Optimizing MS Dynamics AX 2012 R3
Bi requirements checklist
Ms Access ppt
Erp microsoft dynamic ppt
Access lesson 04 Creating and Modifying Forms
Ad

Similar to Ch03 cmpt110 (20)

PPTX
Ch04 Access
 
PPTX
Intro Access
 
PPTX
Welcome-slides-durham-tech
PDF
MS Access 2010 tutorial 5
PDF
Advance Data Analysis & Database
PPTX
Isaac shepherd charlessilver project
PDF
Microsoft access 2010
PDF
Access 2010 Unit B PPT
PPT
Access.05
PPTX
Priyank Goel PPT.pptx
PPT
Overview of MS Access A Beginner's Guide to Creating and Managing Databases.ppt
PPT
HARJOT.ppt gggggggggggggggggggggggggggggggggggggggg
PPTX
New Perspectives: Access.03
PPT
HARJOT.ppt
PDF
Access2007 m2
PPTX
Access Chapter 02
DOCX
Management of database information system
PPTX
Lecture2 slides
PDF
Access tutorial
Ch04 Access
 
Intro Access
 
Welcome-slides-durham-tech
MS Access 2010 tutorial 5
Advance Data Analysis & Database
Isaac shepherd charlessilver project
Microsoft access 2010
Access 2010 Unit B PPT
Access.05
Priyank Goel PPT.pptx
Overview of MS Access A Beginner's Guide to Creating and Managing Databases.ppt
HARJOT.ppt gggggggggggggggggggggggggggggggggggggggg
New Perspectives: Access.03
HARJOT.ppt
Access2007 m2
Access Chapter 02
Management of database information system
Lecture2 slides
Access tutorial
Ad

Recently uploaded (20)

PDF
Close Enough S3 E7 "Bridgette the Brain"
PDF
DPSR MUN'25 (U).pdf hhhhhhhhhhhhhbbnhhhh
PPTX
CPAR-ELEMENTS AND PRINCIPLE OF ARTS.pptx
PDF
the saint and devil who dominated the outcasts
PPTX
G10 HOMEROOM PARENT-TEACHER ASSOCIATION MEETING SATURDAY.pptx
PDF
Love & Romance in Every Sparkle_ Discover the Magic of Diamond Painting.pdf
PPTX
A slideshow about aesthetic value in arts
PPTX
CMU-PPT-LACHICA-DEFENSE FOR RESEARCH PRESENTATION
PPTX
unit5-servicesrelatedtogeneticsinnursing-241221084421-d77c4adb.pptx
PPTX
Green and Blue Illustrative Earth Day Presentation.pptx
PPTX
Socio ch 1 characteristics characteristics
PPTX
CPAR7 ARTS GRADE 112 LITERARY ARTS OR LI
PPTX
The-Evolution-of-Comedy-in-America-A-Conversation-with-Dan-Nainan.pptx
PPTX
Slide_Egg-81850-About Us PowerPoint Template Free.pptx
PPTX
4277547e-f8e2-414e-8962-bf501ea91259.pptx
PPTX
Technical-Codes-presentation-G-12Student
PPTX
Presentation on tradtional textiles of kutch
PPTX
White Green Simple and Professional Business Pitch Deck Presentation.pptx
PDF
Chapter 3 about The site of the first mass
PPTX
Green and Orange Illustration Understanding Climate Change Presentation.pptx
Close Enough S3 E7 "Bridgette the Brain"
DPSR MUN'25 (U).pdf hhhhhhhhhhhhhbbnhhhh
CPAR-ELEMENTS AND PRINCIPLE OF ARTS.pptx
the saint and devil who dominated the outcasts
G10 HOMEROOM PARENT-TEACHER ASSOCIATION MEETING SATURDAY.pptx
Love & Romance in Every Sparkle_ Discover the Magic of Diamond Painting.pdf
A slideshow about aesthetic value in arts
CMU-PPT-LACHICA-DEFENSE FOR RESEARCH PRESENTATION
unit5-servicesrelatedtogeneticsinnursing-241221084421-d77c4adb.pptx
Green and Blue Illustrative Earth Day Presentation.pptx
Socio ch 1 characteristics characteristics
CPAR7 ARTS GRADE 112 LITERARY ARTS OR LI
The-Evolution-of-Comedy-in-America-A-Conversation-with-Dan-Nainan.pptx
Slide_Egg-81850-About Us PowerPoint Template Free.pptx
4277547e-f8e2-414e-8962-bf501ea91259.pptx
Technical-Codes-presentation-G-12Student
Presentation on tradtional textiles of kutch
White Green Simple and Professional Business Pitch Deck Presentation.pptx
Chapter 3 about The site of the first mass
Green and Orange Illustration Understanding Climate Change Presentation.pptx

Ch03 cmpt110

  • 1. Succeeding in Business with Microsoft Access 2013 Analyzing Data For Effective Decision Making
  • 2. Succeeding in Business with Microsoft Access 2013 Chapter Introduction • Filter data in a Microsoft Office Access 2013 database – Retrieve and examine only the records you need – Sort data to rearrange records in a specified order • Create complex queries • Explore advanced queries • Explore queries written in Structured Query Language 2
  • 3. Succeeding in Business with Microsoft Access 2013 Tools Covered In This Chapter • Action queries (update, append, delete, crosstab, and make-table) • Aggregate functions (Avg, Max, Min, Sum) • Calculated field • Comparison and logical operators • Crosstab query • Filter by Form and Filter by Selection • Find duplicates query • Find unmatched records query 3
  • 4. Succeeding in Business with Microsoft Access 2013 Tools Covered In This Chapter (cont’d.) • Immediate IF (IIF) function • Parameter query • Design View • Select query • Simple Query Wizard • SQL commands • Top Values query • Wildcard character 4
  • 5. Succeeding in Business with Microsoft Access 2013 Level 1 Objectives: Organizing and Retrieving Information from a Database • Filter and sort data to make it more meaningful • Create simple queries to answer business questions • Develop queries using comparison criteria and wildcards • Verify and print query results 5
  • 6. Succeeding in Business with Microsoft Access 2013 Filtering and Sorting Data • Filter – Restricts data in single table to create temporary subset of records – See only certain records in table based on specified criteria • Sorting records – Organizing in particular order or sequence – Sort records regardless of whether table filtered 6
  • 7. Succeeding in Business with Microsoft Access 2013 Filtering by Selection • Tools – Filter by Selection • Select particular field in datasheet • Display only data that matches contents of field • Specify only one criterion for filter – Filter by Form 7
  • 8. Succeeding in Business with Microsoft Access 2013 8
  • 9. Succeeding in Business with Microsoft Access 2013 Filtering by Form • Specify two or more criteria • Filter for comparative data – Use comparison operators • AND criteria – Selects records that contain all specified values • OR criteria – Selects records that contain any of specified values 9
  • 10. Succeeding in Business with Microsoft Access 2013 Sorting Data to Increase Information Content • Lets you view the information in a variety of ways • Access sorts records based on primary key values – Use sorting to change order • To sort – Select sort field • Sort on multiple fields – Move fields in Datasheet view so that they are adjacent 10
  • 11. Succeeding in Business with Microsoft Access 2013 Sorting Data To Increase Information Content (cont’d.) • How Access sorts different types of data 11
  • 12. Succeeding in Business with Microsoft Access 2013 Filtering Using the Filter Arrow 12
  • 13. Succeeding in Business with Microsoft Access 2013 Using Queries to Answer Business Questions • Query – Database object – Stores criteria for selecting records from one or more tables based – Save query • Use it again – More powerful than filter • Display only some fields in table • Create fields that perform calculations 13
  • 14. Succeeding in Business with Microsoft Access 2013 Using Queries to Answer Business Questions (cont’d.) • Capabilities of Access queries: – Display selected fields and records from table – Sort records on one or multiple fields – Perform calculations – Generate data for forms, reports, and other queries – Update data in database – Find and display data from two or more tables – Create new tables – Delete records in table based on one or more criteria 14
  • 15. Succeeding in Business with Microsoft Access 2013 Using Queries to Answer Business Questions (cont’d.) • Select query – Ask question based on one or more tables in database – Result displayed in datasheet • Called recordset 15
  • 16. Succeeding in Business with Microsoft Access 2013 Using the Simple Query Wizard to Create a Query • Simple query wizard – Presents list of tables and queries in database • And fields that they contain – Select fields from one or more tables – Wizard creates and displays results 16
  • 17. Succeeding in Business with Microsoft Access 2013 Including Summary Statistics in a Query for Data Analysis • Summary query – Groups records – Calculate sum, average, minimum, or maximum value in each selected field – Count records in table or query • Click Summary Options button 17
  • 18. Succeeding in Business with Microsoft Access 2013 18 Figure 3.7: Creating a summary query with the Simple Query Wizard
  • 19. Succeeding in Business with Microsoft Access 2013 Creating a Query in Design View • Select Query window in Design view has two sections – Area for field lists at top of window – Design grid below it • Add tables for query to top part of window – Appear as field lists • Query by example (QBE) – Typing search value as a criterion 19
  • 20. Succeeding in Business with Microsoft Access 2013 20
  • 21. Succeeding in Business with Microsoft Access 2013 Creating Queries with Multiple Criteria • Most queries involve more than one criterion • Represent AND criteria – Enter conditions in same criteria row in query design grid • Specify OR criteria – Use “or” row of query design grid 21
  • 22. Succeeding in Business with Microsoft Access 2013 22 Figure 3.10: Setting criteria for the query in Design view
  • 23. Succeeding in Business with Microsoft Access 2013 Specifying Sort Order in Queries • Query results appear in same order as data from underlying tables – Unless specify sort order when designing query • Sort order determined from left to right 23
  • 24. Succeeding in Business with Microsoft Access 2013 Running a Query • Click Run button in the Results group – Access displays datasheet of records • Save query – Save only design – Not values from tables displayed in results 24
  • 25. Succeeding in Business with Microsoft Access 2013 Enhancing Query Criteria to Improve Data Analysis • Expand criteria by using – Wildcards – Comparison operators 25
  • 26. Succeeding in Business with Microsoft Access 2013 Using Wildcards for Inexact Query Matches • Wildcard character – Placeholder – Stands for one or more characters • Comment fields – Use same keywords throughout comments – Easily retrieve records later – Use wildcards when specifying keyword as a query criterion • To select records that contain characters before and after keyword 26
  • 27. Succeeding in Business with Microsoft Access 2013 27
  • 28. Succeeding in Business with Microsoft Access 2013 Using Wildcards for Inexact Query Matches (cont’d.) • Access inserts – Word “LIKE” for criteria with wildcards quotation marks around text • LIKE “*Spanish*” – Pound signs around dates • #12/*/2013# 28
  • 29. Succeeding in Business with Microsoft Access 2013 Using Comparison Operators to Refine Query Criteria • Comparison operators – Compare value in field with range of values in criterion • Clear the design grid to create or modify a query – Start with same field list but blank grid 29
  • 30. Succeeding in Business with Microsoft Access 2013 30
  • 31. Succeeding in Business with Microsoft Access 2013 Verifying and Printing Query Results • Verify query results before – Distributing query to others – Using it as basis for decisions • Use business knowledge – Determine whether results adequately answer question • Print query datasheet 31
  • 32. Succeeding in Business with Microsoft Access 2013 Modifying Query Datasheets • Improve appearance of query or table datasheet • Resize column widths in any datasheet – Double-click line between field names to resize columns to best fit 32
  • 33. Succeeding in Business with Microsoft Access 2013 33
  • 34. Succeeding in Business with Microsoft Access 2013 Level 1 Summary • Use filtering and sorting to change data display • Develop queries using – Simple query wizard – Design view • Use comparison operators and wildcards to make queries more flexible • Verify query results using business knowledge 34
  • 35. Succeeding in Business with Microsoft Access 2013 Level 2 Objectives: Creating More Complex Queries • Design queries that compare data from more than one table • Refine table relationships by specifying the join type • Perform calculations in queries • Customize queries and their results 35
  • 36. Succeeding in Business with Microsoft Access 2013 36
  • 37. Succeeding in Business with Microsoft Access 2013 Using Queries to Find Duplicate Records • Duplicates Query Wizard – Searches for duplicate values in fields – Improves business operations – Designed to identify records that contain same information in particular field 37
  • 38. Succeeding in Business with Microsoft Access 2013 Using Queries to Find Unmatched Records • Find Unmatched Query Wizard – Compares records in two specified tables or recordsets – Finds all records in one table or query that have no related records in second table or query – Requires that two tables being compared have common field 38
  • 39. Succeeding in Business with Microsoft Access 2013 Limiting the Records in the Query Results • Limiting results to only a few records often aids analysis • Top and Bottom Values – Set a sort order for the field – Descending to display the records with the highest values – Ascending to display the records with the smallest values 39
  • 40. Succeeding in Business with Microsoft Access 2013 40
  • 41. Succeeding in Business with Microsoft Access 2013 Using Parameter Values in Queries • Parameter values – Phrase usually in form of a question or instruction – Enclosed in square brackets – Serves as prompt to user to enter value – Example • [Enter a job ID:] 41
  • 42. Succeeding in Business with Microsoft Access 2013 42
  • 43. Succeeding in Business with Microsoft Access 2013 Analyzing Data from More than One Table • Data from more than one table required to answer question – Combine records from two or more tables – Display only information needed • Work in Design View to specify criteria for selecting records from multiple tables • Lines between tables link primary key to foreign key field – Primary key designated with 1 – Foreign key designated with ∞ 43
  • 44. Succeeding in Business with Microsoft Access 2013 Analyzing Data from More than One Table (cont’d.) • Join tables – Linking of tables using primary and foreign keys – Established relationship – Or • Each table shares field with same or compatible data type • One join field primary key • If tables do not include fields that can be joined – Add one or more extra tables or queries – Link tables that contain the data 44
  • 45. Succeeding in Business with Microsoft Access 2013 Analyzing Data from More than One Table (cont’d.) • Use queries as source of underlying data for another query in place of one or more tables • Create queries based on more than one object – Should not use any table or query that does not have common field with at least one of the other tables or queries – Otherwise Access displays every combination of records between two tables 45
  • 46. Succeeding in Business with Microsoft Access 2013 Refining Relationships with Appropriate Join Types • Inner join – Displays all records in one table that have corresponding values in common field in another table – Records must match before being displayed in query results • Outer join – Displays all records of one table • Regardless of whether corresponding record is stored in related table 46
  • 47. Succeeding in Business with Microsoft Access 2013 47 Figure 3.34: Inner join
  • 48. Succeeding in Business with Microsoft Access 2013 48
  • 49. Succeeding in Business with Microsoft Access 2013 49 Figure 3.36: Right outer join
  • 50. Succeeding in Business with Microsoft Access 2013 Refining Relationships with Appropriate Join Types (cont’d.) • Outer join types – Left – Right • Use Join Properties dialog box – To change join type – By default, tables are related using inner joins – Options for outer joins 50
  • 51. Succeeding in Business with Microsoft Access 2013 Using Logical Operators to Specify Multiple Conditions • Logical operators – Test values that can only be true or false • Place conditions in separate fields in same criteria row of design grid – All conditions in row must be met to select record • NOT logical operator – Excludes values that don’t meet criterion 51
  • 52. Succeeding in Business with Microsoft Access 2013 52
  • 53. Succeeding in Business with Microsoft Access 2013 Performing Calculations with Queries • Any information derived from fields in table or query should be calculated in query – Rather than included as data in table • Calculation types – Predefined • Compute amounts for groups of records or for all records combined in query – Custom • Perform numeric date and text computations on each record • Using data from one or more fields 53
  • 54. Succeeding in Business with Microsoft Access 2013 Calculating Statistical Information • Aggregate functions – Mathematic and statistical operations – Apply to records that meet query’s selection criteria 54
  • 55. Succeeding in Business with Microsoft Access 2013 55
  • 56. Succeeding in Business with Microsoft Access 2013 56 Figure 3.43: Using aggregate functions in a query
  • 57. Succeeding in Business with Microsoft Access 2013 Creating Calculated Fields in a Query • Expression – Arithmetic formula for calculation – Use standard arithmetic operators – Use parenthesis for complex expressions • Calculated field – Add to query design grid – Type expression • Expression Builder – Build complex expressions 57
  • 58. Succeeding in Business with Microsoft Access 2013 Creating Calculated Fields in a Query (cont’d.) • Function – Performs standard calculation – Returns value • Date() – Provides today’s date • Field properties – Change format and number of decimal places for calculated field 58
  • 59. Succeeding in Business with Microsoft Access 2013 59
  • 60. Succeeding in Business with Microsoft Access 2013 Concatenating in Queries • Concatenation – Combining contents of two or more fields – Operator • & – Example • Name [EmpFirst]& " " & [EmpLast] 60
  • 61. Succeeding in Business with Microsoft Access 2013 Level 2 Summary • Use queries to select from more than one table • Join types – Inner – Right outer – Left outer • Calculated field types – Predefined – Custom 61
  • 62. Succeeding in Business with Microsoft Access 2013 Level 3 Objectives: Exploring Advanced Queries and Queries Written in Structured Query Language • Calculate and restructure data to improve analysis • Examine and create advanced types of queries • Make decisions in a query using the immediate IF (IIF) function • Develop queries using SQL 62
  • 63. Succeeding in Business with Microsoft Access 2013 Analyzing Query Calculations • More advanced queries – Crosstab query • Most useful for preparing data for further analysis – Action queries • Change or move many records in one operation – Four types of action queries: • Append, update, delete, and make-table 63
  • 64. Succeeding in Business with Microsoft Access 2013 Analyzing Query Calculations (cont’d.) • Crosstab queries – Special type of totals query – Perform aggregate function calculations on values of one database field – Determine exactly how summary data appears in results – Calculate and restructure data • Analyze it more easily – Work especially well with time-series data 64
  • 65. Succeeding in Business with Microsoft Access 2013 Creating a Crosstab Query • To create: – Use Design View • Start with select query that includes numeric values or summary calculations – Use the Crosstab Query Wizard • Guides you through the steps • Shows samples of how the crosstab results will look 65
  • 66. Succeeding in Business with Microsoft Access 2013 66
  • 67. Succeeding in Business with Microsoft Access 2013 Modifying Data Using Queries • Action queries – Modify data in table – Add records to or delete records from table – Create new table • Backup data before using action query 67
  • 68. Succeeding in Business with Microsoft Access 2013 68
  • 69. Succeeding in Business with Microsoft Access 2013 69
  • 70. Succeeding in Business with Microsoft Access 2013 Archiving Data with Make-table Queries • Make-table query – Creates table from some or all of the fields and records in existing table or query – Access does not delete selected fields and records from existing table 70
  • 71. Succeeding in Business with Microsoft Access 2013 Adding Records to Tables with Append Queries • Append query – Select records from one or more tables by setting criteria – Add those records to end of another table – Selected records also remain in original tables – Table to which records added must already exist – Can bring data from another source into database 71
  • 72. Succeeding in Business with Microsoft Access 2013 Removing Records from Tables with Delete Queries • Delete query – Removes information from table – Based on specified criteria – All records meeting criteria permanently removed • Create select query first – Convert to delete query • Cascading deletes 72
  • 73. Succeeding in Business with Microsoft Access 2013 Updating Data with an Update Query • Update query – Changes values of data in one or more existing tables – Create select query first • Change type to update query 73
  • 74. Succeeding in Business with Microsoft Access 2013 Making Decisions in Queries • IF statement – Tests condition – Takes one action if condition true – Takes another action if condition false • IIF function – Make IF decision – Format • IIF(condition to test, what to do if true, what to do if false) 74
  • 75. Succeeding in Business with Microsoft Access 2013 Customizing Queries Using Structured Query Language • Access designed as database management system (DBMS) for: – Small businesses – Or departments within large businesses • Structured query language – Common query language of most DBMSs – Use to query/update/manage relational databases • Create query in Design View – Access translates entries and criteria into SQL statements 75
  • 76. Succeeding in Business with Microsoft Access 2013 Customizing Queries Using Structured Query Language (cont’d.) • View statements by switching from Design view to SQL view • SELECT statement defines: – What data query should retrieve from database – How it should present data 76
  • 77. Succeeding in Business with Microsoft Access 2013 Exploring the Components of an SQL Query • Keywords – Use to construct SQL statements • Most developers place each statement on separate line – To make SQL code easy to read 77
  • 78. Succeeding in Business with Microsoft Access 2013 78
  • 79. Succeeding in Business with Microsoft Access 2013 Creating a Union Query Using SQL • Union query – Combine, or unite, the results from two or more select queries 79
  • 80. Succeeding in Business with Microsoft Access 2013 Level 3 Summary • Crosstab and Action queries • IFF function • SQL – Use SQL view to edit SQL directly 80
  • 81. Succeeding in Business with Microsoft Access 2013 Chapter Summary • Queries retrieve data from one or more tables – Action queries update data – Perform calculations – Make decisions using IIF function • SQL – Used to interact with relational databases – Use SQL view to view/edit SQL statements generated by Access 81