28
Microsoft Office 2007 - Microsoft Office 2007 - Illustrated Illustrated Creating Multiple Table Creating Multiple Table Queries Queries

Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

Embed Size (px)

Citation preview

Page 1: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

Microsoft Office 2007 - IllustratedMicrosoft Office 2007 - Illustrated

Creating Multiple Table Creating Multiple Table QueriesQueries

Page 2: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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

Page 3: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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

Page 4: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

Building Select QueriesBuilding Select Queries

Methods:Methods:

• Simple Query WizardSimple Query Wizard

• Query Design ViewQuery Design View

4Microsoft Office 2007-Illustrated

Page 5: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

Query Design ViewQuery Design View

5Microsoft Office 2007-Illustrated

One-to-many join lines

Field lists

Query grid identifies fields in query

Page 6: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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

Page 7: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

Specifying Sort OrdersSpecifying Sort Orders

7Microsoft Office 2007-Illustrated

Primary sort order

Secondary sort order

Page 8: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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

Page 9: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

Developing AND CriteriaDeveloping AND Criteria

9Microsoft Office 2007-Illustrated

AND criteria entered on the same row

Page 10: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

Common Comparison OperatorsCommon Comparison Operators

10Microsoft Office 2007-Illustrated

Page 11: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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

Page 12: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

Developing OR CriteriaDeveloping OR Criteria

12Microsoft Office 2007-Illustrated

Enter OR criteria on different rows

Page 13: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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

Page 14: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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.

Page 15: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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

Page 16: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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

Page 17: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

Arithmetic OperatorsArithmetic Operators

17Microsoft Office 2007-Illustrated

Page 18: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

Common FunctionsCommon Functions

18Microsoft Office 2007-Illustrated

Page 19: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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

Page 20: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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

Page 21: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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

Page 22: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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

Page 23: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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

Page 24: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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

Page 25: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

Building PivotChartsBuilding PivotCharts

25Microsoft Office 2007-Illustrated

Drag fields from the field list to the field locations on the PivotChart

Page 26: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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

Page 27: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

Comparing PivotTables, Comparing PivotTables, PivotCharts, and Crosstab PivotCharts, and Crosstab QueriesQueries

27Microsoft Office 2007-Illustrated

Page 28: Microsoft Office 2007 - Illustrated Creating Multiple Table Queries

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