Download presentation
Presentation is loading. Please wait.
Published byBritney Eagleston Modified over 9 years ago
1
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Access 2010 Chapter 5 Enhancing Queries
2
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall2 Objectives Create calculated fields in a query Use aggregate functions in a query Create a crosstab query Find duplicate and unmatched records Create a parameter query
3
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall3 Objectives Create a make table query Create an append query Create a delete query Create an update query Modify the join type
4
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall4 Create Calculated Fields in a Query Calculated fields created in queries –Obtain data by performing calculations Example: Profit per Item:[Selling Price] * [Cost] Field Name Colon Expression Calculated Field
5
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall5 Create Calculated Fields in a Query Steps to create calculated field: 1.Go to blank column in query design grid 2.Enter name for calculated field 3.Type colon (:) after calculated field name 4.Type expression after equal (=) Expression: formula performing calculation
6
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall6 Create Calculated Fields in a Query Arithmetic operators are mathematical symbols –Used to build calculated field expressions OperatorDescriptionExampleResult +AdditionCost:[Price]+[Tax]Adds the value in the Price field to the value in the tax field and displays the result in the Cost field. -SubtractionCost:[Price]-[Markdown]Subtracts the value in the Markdown field from the value in the Price field and displays the result in the Cost Field.
7
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall7 Create Calculated Fields in a Query OperatorDescriptionExampleResult *MultiplicationTax:[Price]*.05Multiplies the value in the Price field by.05 (5%) and displays the result in the Tax field. (Note: This is an asterisk, not an x.) /DivisionAverage:[Total]/3Divides the value in the Total field by 3 and displays result in the Average field. ^ExponentiationRequired:2^[Bits]Raises 2 to the power of the value in the Bits field and stores the result in the Required field.
8
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall8 Create Calculated Fields in a Query OperatorDescriptionExampleResult \Integer division Average:[Children]\ [Families] Divides the value in the Children field by the value in the Families field and displays the integer portion – the digits to the left of the decimal point – in the Average field. ModModulo or modulus division Remainder:[Year]Mod4Divides the value in the Year field by 4 and displays the remainder in the Remainder field. In the example, if the year is 2009, the answer (Remainder) would be 1 – 2009 divided by 4, which gives a quotient of 502 with a remainder of 1.
9
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall9 Create Calculated Fields in a Query Two methods to enter calculated fields: –Zoom dialog box Can see entire expression Right-click empty column, click Zoom –Entry in empty Field box on query design grid
10
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall10 Create Calculated Fields in a Query Square bracket usage and query fields in calculated field expressions –Square brackets NOT required when field name one word –Square brackets required when field name multiple words (has spaces)
11
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall11 Create Calculated Fields in a Query Number values in calculated fields –Not enclosed in square brackets –Not formatted
12
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall12 Create Calculated Fields in a Query Use Properties to format calculated field To display Property Sheet –Select Design tab –Click Property Sheet in Show/Hide group Alternative method –Right-click field, and select Properties
13
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall13 Create Calculated Fields in a Query Format box on the General tab on the Property Sheet
14
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall14 Use Aggregate Functions in a Query Aggregate function performs calculation on column of data –Returns a single value –Examples: Sum, Average, and Count To add Total row to query –Select Home tab Click Totals button in Records group
15
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall15 Use Aggregate Functions in a Query Totals button in the Records group on the Home tab
16
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall16 Use Aggregate Functions in a Query Aggregate function overview FunctionDescription SumAdds the values in a column. AverageCalculates the average value for a column, ignoring null values. CountCounts the number of items in a column, ignoring null values. MaximumDisplays the item with the highest value. MinimumDisplays items with the lowest value. Standard Deviation Measures how widely values are dispersed from the mean value. VarianceMeasures the statistical variance of all values in the column. If the table has less than two rows, a null value is displayed.
17
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall17 Use Aggregate Function in a Query Totals query calculates subtotals across record groups –Used as source for other objects Create table total row –Select Design tab –Then click Totals button in Show/Hide group, –Total row appears under Table row on design grid
18
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall18 Use Aggregate Function in a Query Group By in the Total row in the design grid
19
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall19 Use Aggregate Function in a Query Change name of aggregate field –In Design view, click field name, and then on Design tab, in Show/Hide group, click Property –Total query can be based on: One field Multiple fields
20
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall20 Use Aggregate Function in a Query Based on one field: Based on multiple fields:
21
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall21 Create a Crosstab Query Crosstab query uses aggregate function –Grouped by two types of information –Displays data in spreadsheet-like format –Summarizes large amount of data
22
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall22 Create a Crosstab Query Crosstab query has at least one of each –Row heading –Column heading –Summary field Should be based on select query Created through Crosstab Query Wizard
23
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall23 Create a Crosstab Query Crosstab query
24
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall24 Find Duplicate and Unmatched Records Find Duplicate Query Wizard –Locates duplicate records in table –Take care determining duplication of records –Prior to deleting duplicate records, check table relationships
25
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall25 Find Duplicate and Unmatched Records Find Unmatched Query Wizard –Locates records where record(s) in one table have no matching record in a relating table Cannot use Find Unmatched Query Wizard –When table has multivalued fields
26
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall26 Create a Parameter Query Parameter query prompts for criteria –Displays records based on criteria entered Use square brackets in criteria prompt Example: –In CatName field criteria row: Type [Enter a Category] Parameter query will use entry as criteria
27
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall27 Create a Parameter Query Enter Parameter Value dialog box
28
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall28 Create a Make Table Query Action query enables you to –Create new table –Change data in existing table To run an action query –Must be in trusted location, OR –You must enable the content
29
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall29 Create a Make Table Query Make table query is an action query –Creates new table Extracts data from one or more tables –Use select query as basis Give unique name to make table query
30
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall30 Create a Make Table Query Make table button in the Query Type group on the Design tab
31
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall31 Create an Append Query Append query is an action query –Adds new records to existing table –Adds data from another table Used when –Data already exists in one table, and –Do not want to enter manually in another From same or different databases
32
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall32 Create an Append Query Access compares: –Fields in append query with destination table fields If match found: –Adds names of destination fields If no match found: –Destination field left blank
33
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall33 Create an Append Query Matching fields from destination table
34
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall34 Create a Delete Query Delete query is an action query –Removes records from existing table Use select query as basis Used to delete records quickly Before running, perform backup
35
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall35 Create a Delete Query To delete records on one side of relationship, either –Delete relationship, OR –Enable Cascade Delete Related Records To delete records on many side of relationship –No changes, deletion of relationship required
36
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall36 Create a Delete Query
37
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall37 Create an Update Query Update query is an action query Used to add, change, or delete data Can change data –For large number of records quickly –In multiple tables at one time Can create with an expression
38
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall38 Create an Update Query Adding an expression in Update To row
39
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall39 Create an Update Query Some restrictions running update query include –Calculated fields –Use of total or crosstab queries as source –Autonumber fields –Fields in union queries
40
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall40 Modify the Join Type Joins pull correct records from related tables Table relationships based on common fields Join line displays between related tables
41
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall41 Modify the Join Type Inner join is the default join Inner join query selects records where common field exists Outer join query displays records whether records match or not
42
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall42 Modify the Join Type Left outer join –Displays all records on one side –Does not need a match on many side Right outer join –Displays all records on many side –Does not need a match on one side –Not possible if referential integrity on
43
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall43 Modify the Join Type Join Properties dialog box
44
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall44 Covered Objectives Create calculated fields in a query Use aggregate functions in a query Create a crosstab query Find duplicate and unmatched records Create a parameter query
45
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall45 Covered Objectives Create a make table query Create an append query Create a delete query Create an update query Modify the join type
46
with Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall46 46 All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America. Copyright © 2011 Pearson Education, Inc. Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.