Upload
teresa-caines
View
241
Download
6
Embed Size (px)
Citation preview
Microsoft Office 2007 - IllustratedMicrosoft Office 2007 - Illustrated
Creating Multiple Table Creating Multiple Table QueriesQueries
ObjectivesObjectives
• Build select queriesBuild select queries
• Use multiple sort ordersUse multiple sort orders
• Develop AND criteriaDevelop AND criteria
• Develop OR criteriaDevelop OR criteria
(continued)(continued)
2Microsoft Office 2007-Illustrated
Objectives Objectives (continued)(continued)
• Create calculated fieldsCreate calculated fields
• Build summary queriesBuild summary queries
• Build crosstab queriesBuild crosstab queries
• Build PivotTables and PivotChartsBuild PivotTables and PivotCharts
3Microsoft Office 2007-Illustrated
Building Select QueriesBuilding Select Queries
Methods:Methods:
• Simple Query WizardSimple Query Wizard
• Query Design ViewQuery Design View
4Microsoft Office 2007-Illustrated
Query Design ViewQuery Design View
5Microsoft Office 2007-Illustrated
One-to-many join lines
Field lists
Query grid identifies fields in query
Using Multiple Sort OrdersUsing Multiple Sort Orders
• Sort orders are evaluated in a left-to-Sort orders are evaluated in a left-to-right orderright order
• Use the Show check box to sort on a Use the Show check box to sort on a field but not show it in the query field but not show it in the query datasheetdatasheet
6Microsoft Office 2007-Illustrated
Specifying Sort OrdersSpecifying Sort Orders
7Microsoft Office 2007-Illustrated
Primary sort order
Secondary sort order
Developing AND CriteriaDeveloping AND Criteria
• AND criteria are entered on the AND criteria are entered on the samesame row of the query gridrow of the query grid
• AND criteria must AND criteria must bothboth be true for the be true for the record to display in the datasheetrecord to display in the datasheet
• AND criteria further limit the number of AND criteria further limit the number of records in the datasheetrecords in the datasheet
• Comparison operators or wildcard Comparison operators or wildcard characters may be used in criteriacharacters may be used in criteria
8Microsoft Office 2007-Illustrated
Developing AND CriteriaDeveloping AND Criteria
9Microsoft Office 2007-Illustrated
AND criteria entered on the same row
Common Comparison OperatorsCommon Comparison Operators
10Microsoft Office 2007-Illustrated
Developing OR CriteriaDeveloping OR Criteria
• OR criteria are entered on OR criteria are entered on differentdifferent rows of the query gridrows of the query grid
• OR criteria may OR criteria may eithereither be true for the be true for the record to display in the datasheetrecord to display in the datasheet
• OR criteria further expand the OR criteria further expand the number of records in the datasheetnumber of records in the datasheet
• Comparison operators or wildcard Comparison operators or wildcard characters may be used in criteriacharacters may be used in criteria
11Microsoft Office 2007-Illustrated
Developing OR CriteriaDeveloping OR Criteria
12Microsoft Office 2007-Illustrated
Enter OR criteria on different rows
Criteria WildcardsCriteria Wildcards
• An asterisk (*) searches for any An asterisk (*) searches for any number of charactersnumber of characters
• A question mark (?) searches for any A question mark (?) searches for any single charactersingle character
• A pound sign (#) searches for any A pound sign (#) searches for any single numbersingle number
13Microsoft Office 2007-Illustrated
Using Wildcard CharactersUsing Wildcard Characters
•
14Microsoft Office 2007-Illustrated
Using a wildcard character in query criteria.Like “7/*/2010” finds all dates in July of 2010.
Creating Calculated FieldsCreating Calculated Fields• Create a calculated field in the field cell of Create a calculated field in the field cell of
the query gridthe query grid• Calculated fields follow this patternCalculated fields follow this pattern
NewFieldName:expressionNewFieldName:expression
• Expressions may include field names, Expressions may include field names, operators, and functions such as Sumoperators, and functions such as Sum
• Surround field names in [square brackets]Surround field names in [square brackets]• Example: LeadTime:[TourStartDate]-Example: LeadTime:[TourStartDate]-
[SaleDate][SaleDate]
•15Microsoft Office 2007-Illustrated
Creating Calculated FieldsCreating Calculated Fields
16Microsoft Office 2007-Illustrated
Lead Time is the new calculated field name
[TourStartDate]-[SaleDate] is the expression
A colon (:) separates the field name from the expression
Arithmetic OperatorsArithmetic Operators
17Microsoft Office 2007-Illustrated
Common FunctionsCommon Functions
18Microsoft Office 2007-Illustrated
Building Summary QueriesBuilding Summary Queries
• A summary query calculates A summary query calculates statistics about a group of recordsstatistics about a group of records
• Use the Total row in the query grid to Use the Total row in the query grid to specify how records are grouped and specify how records are grouped and summarizedsummarized
• The datasheet of summary queries The datasheet of summary queries cannot be updated because each cannot be updated because each row represents several recordsrow represents several records
19Microsoft Office 2007-Illustrated
Summary Query Design ViewSummary Query Design View
20Microsoft Office 2007-Illustrated
Totals button
Category is the grouping field
Total row is added to query grid
SalesNo values are counted
Cost values summed
Building Crosstab QueriesBuilding Crosstab Queries
• Crosstab queries calculate statistics Crosstab queries calculate statistics about a group of records using both a about a group of records using both a row and a column headingrow and a column heading
• Use the Crosstab Query Wizard to Use the Crosstab Query Wizard to create a crosstab querycreate a crosstab query
• Use the Total and Crosstab rows in Use the Total and Crosstab rows in the query grid to specify the crosstab the query grid to specify the crosstab settingssettings
21Microsoft Office 2007-Illustrated
Building Crosstab QueriesBuilding Crosstab Queries
22Microsoft Office 2007-Illustrated
Cost values summed by TourName and Category
Row Headings (values from Category field)
Column Headings (values from TourName field
Other Query WizardsOther Query Wizards
23Microsoft Office 2007-Illustrated
• Find Duplicates Query WizardFind Duplicates Query Wizard finds finds whether a table contains duplicate whether a table contains duplicate values in one or more fieldsvalues in one or more fields
• Find Unmatched Query WizardFind Unmatched Query Wizard finds records in one table that do not finds records in one table that do not have related records in another tablehave related records in another table
Building PivotTables and Building PivotTables and PivotChartsPivotCharts• Use the PivotTable or PivotChart Use the PivotTable or PivotChart
View of any existing table, query, or View of any existing table, query, or formform
• Changes made to either the Changes made to either the PivotTable or PivotChart view are PivotTable or PivotChart view are automatically applied to the otherautomatically applied to the other
24Microsoft Office 2007-Illustrated
Building PivotChartsBuilding PivotCharts
25Microsoft Office 2007-Illustrated
Drag fields from the field list to the field locations on the PivotChart
Building PivotTablesBuilding PivotTables
26Microsoft Office 2007-Illustrated
State field moved from PivotTable and filtered to display only Kansas records
City field provides column values
FirstContact is in the row heading area
Count of Lname for each FirstContact and City
Comparing PivotTables, Comparing PivotTables, PivotCharts, and Crosstab PivotCharts, and Crosstab QueriesQueries
27Microsoft Office 2007-Illustrated
SummarySummary
• Select queries are the most common Select queries are the most common type of querytype of query
• Use select queries to:Use select queries to:• Select a subset of fields and recordsSelect a subset of fields and records• Sort dataSort data• Create calculated fieldsCreate calculated fields
• Use Summary, Crosstab, PivotTable, Use Summary, Crosstab, PivotTable, and PivotCharts to show summarized and PivotCharts to show summarized informationinformation
28Microsoft Office 2007-Illustrated