Ch03 Access

2,510 views

Published on

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,510
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
152
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Ch03 Access

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

×