Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Advantage Series © 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating Select Queries Chapter 6 Microsoft Office Access 2003.

Similar presentations


Presentation on theme: "The Advantage Series © 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating Select Queries Chapter 6 Microsoft Office Access 2003."— Presentation transcript:

1 The Advantage Series © 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating Select Queries Chapter 6 Microsoft Office Access 2003

2 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.1 Using the Query Design View The most common query is the Select query –Gathers and arranges data according to the user’s criteria create, and customize select queries Queries can serve as the basis for forms and reports The Query design view allows you to…

3 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.1.1 Creating a Query in Design View Figure 6.1 AC0600 Database window

4 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.1.1 Creating a Query in Design View Figure 6.2 Query Design window Table Pane Split bar for sizing the shared space between the Table pane and query Design grid Query Design Grid The intersection of a column and row is sometimes called a cell.

5 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.1.1 Creating a Query in Design View Figure 6.3 Adding a field to the query Design grid The mouse pointer changes to a field box when you drag it into the query Design grid.

6 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.1.1 Creating a Query in Design View Figure 6.4 Dynaset for Student Phone List query

7 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.1.2 Modifying a Query Object Figure 6.5 Moving a column in the query Design grid

8 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.1.2 Modifying a Query Object Figure 6.6 Dynaset for modified Student Phone List query

9 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.1.3 Specifying Search Criteria Figure 6.7 Dynaset result for “Business” students

10 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.1.3 Specifying Search Criteria Figure 6.8 Specifying a conditional statement Field name to evaluate and display Table that the field belongs to Conditional statement for limiting the display of records

11 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.1.3 Specifying Search Criteria Figure 6.9 Dynaset result for students over the age of 22

12 © 2004 The McGraw-Hill Companies, Inc. All rights reserved Operator/ Criteria… Description… > Greater than; find numbers or dates that are greater than the specified value. For example, >5000 finds all records where the field value is more than 5,000. (Note: Don’t enter commas in numeric queries.) >= Greater than or equal to; find numbers or dates that are greater than or equal to the specified value. < Less than; find numbers or dates that are less than or equal to the specified value. For example, <#05/27/2005# retrieves all records with a date value less than May 27, 2005. (Note: Date values are surrounded by number symbols in conditional statements.) <= Less than or equal to; find numbers or dates that are less than or equal to the specified value. 6.1.3 Specifying Search Criteria Table 6.1 Query Operators

13 © 2004 The McGraw-Hill Companies, Inc. All rights reserved Operator/ Criteria… Description… Between X And YList those records that contain values between X and Y inclusive. For example, use Between 21 And 65 in an Age field and use Between #01/01/2005# And #12/31/2005# in a Date field. X Or YList those records that contain either X or Y. Not XList those records not containing X. Like “Sm?th”List those records in which the first letters are “Sm”, the next letter is unknown, and the last two letters are “th”. Example: Smith, Smyth. Like “Ch*ng”List those records in which the first letters are “Ch”, the middle letters are unknown, and the last letters are “ng”. Example: Chang, Chickering. Like “*on*”List those records in which the field value contains the letter combination “on”. Example: Conditional, Monday. Like “*/*/2005”List those records that end with “2005” in the Date field. 6.1.3 Specifying Search Criteria Table 6.1 Query Operators

14 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.2 Creating Multi-Table Queries Reduces redundant information Relationships among tables can be defined in the query design view Access can create relationships among tables automatically if –the tables contain a field of the same name and data type, and –one of the fields is a primary key Access allows tables to be joined so that information can be shared

15 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.2.1 Adding and Removing Tables Figure 6.10 Relationships window for tables in the AC0600 database

16 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.2.1 Adding and Removing Tables Figure 6.11 Modifying the query Design window

17 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.2.2 Adding and Removing Fields Figure 6.12 Creating a multi-table query

18 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.2.2 Adding and Removing Fields Figure 6.13 Dynaset result for a multi-table query

19 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.2.3 Specifying Multi-Table Criteria Figure 6.14 Dynaset result for courses having instructor surnames beginning with “K”

20 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.2.4 Previewing and Printing the Dynaset Figure 6.15 Print Preview window for a query

21 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.3 Enhancing a Select Query Sort the results of a query Apply filters to limit the display of records in a dynaset Apply Conditional Logic statements to create more complex search and retrieval operations –Use AND and/or OR to combine criteria statements –Specify multiple criteria in different fields, or –Specify multiple criteria in a single field With Select queries, Access can also…

22 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.3.1 Sorting Query Results Figure 6.16 Query Design window with the Students field list

23 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.3.1 Sorting Query Results Figure 6.17 Dynaset result sorted by the LastName field

24 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.3.1 Sorting Query Results Figure 6.18 Specifying a multi-key sort order Primary sort key Secondary sort key

25 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.3.2 Applying Filters to the Dynaset Figure 6.19 Dynaset result filtered for City equals Bellevue

26 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.3.2 Applying Filters to the Dynaset Figure 6.20 Viewing filter criteria in the query Design window The field list object displays fields from another query object. The Filter By Form criterion is transferred into the Criteria row.

27 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.3.3 Specifying Multiple Criteria in Different Fields Figure 6.21 Setting up a query

28 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.3.3 Specifying Multiple Criteria in Different Fields Figure 6.22 Dynaset result for Arts students living in Kirkland who are over 20 years old

29 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.3.3 Specifying Multiple Criteria in Different Fields Figure 6.23 Entering criterion on separate rows of the query Design grid

30 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.3.4 Specifying Multiple Criteria in a Single Field Figure 6.24 Dynaset result for students who live in Redmond or Bellevue

31 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.3.4 Specifying Multiple Criteria in a Single Field Figure 6.25 Using AND and OR operators in the query Design grid

32 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.3.4 Specifying Multiple Criteria in a Single Field Figure 6.26 Dynaset result for the Student Custom Query

33 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.4 Performing Calculations Computes a result for each record returned in a dynaset Computes a single summary result for all records returned in a dynaset Row-by-Row calculation… Aggregate calculation…

34 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.4.1 Creating a Calculated Field Figure 6.27 Setting up a query

35 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.4.1 Creating a Calculated Field Figure 6.28 Dynaset result for student grades in COM200

36 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.4.1 Creating a Calculated Field Figure 6.29 Dynaset result after scaling student grades upward by six percent

37 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.4.1 Creating a Calculated Field Figure 6.30 Viewing a calculated field in the query Design grid

38 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.4.2 Setting Field Properties Figure 6.31 Field Properties dialog box

39 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.4.2 Setting Field Properties Figure 6.32 Dynaset result showing formatted values in a calculated field Formatted to display with a fixed number format and three decimal places.

40 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.4.3 Using the Expression Builder Figure 6.33 Expression Builder dialog box The Expression box displays your selections as they are made. Select a main folder in the left-hand list box to display a new set of subcategories and element values in the next two list boxes. Select common operators by clicking these buttons. Click this button to paste a value from the right-most bottom box into the Expression box above.

41 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.4.3 Using the Expression Builder Figure 6.34 Concatenati ng field values using the ampersand (&) symbol

42 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.4.3 Using the Expression Builder Figure 6.35 Modifying column widths in the query Design grid

43 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.4.3 Using the Expression Builder Figure 6.36 Dynaset result for concatenated and calculated fields

44 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.4.4 Creating Summary Queries Figure 6.37 Creating a summary query When the Totals button is active, the Total row appears in the Design grid. The Total drop-down list box displays the calculation options.

45 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.4.4 Creating Summary Queries Figure 6.38 Grouping calculations in a summary query

46 © 2004 The McGraw-Hill Companies, Inc. All rights reserved 6.4.4 Creating Summary Queries Figure 6.39 Performing multiple calculations in a summary query


Download ppt "The Advantage Series © 2004 The McGraw-Hill Companies, Inc. All rights reserved Creating Select Queries Chapter 6 Microsoft Office Access 2003."

Similar presentations


Ads by Google