CS&E 1111 AcQueries Querying in Access Sorting data Aggregating Data Performing Calculations Objectives: Learn how to use the Access Query Design Tool.

Slides:



Advertisements
Similar presentations
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 10 – Designing.
Advertisements

Concepts of Database Management Seventh Edition
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Query-By-Example (QBE) 2440: 180 Database Concepts.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 3 1 Microsoft Office Access 2003 Tutorial 3 – Querying a Database.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making.
Querying a Database Using the Select Query Window
Querying a Database Microsoft Office Access 2003.
Concepts of Database Management Sixth Edition
Microsoft Access 2010 Chapter 7 Using SQL.
Tutorial 5: Working with Excel Tables, PivotTables, and PivotCharts
1 Access Lesson 3 Creating Queries Microsoft Office 2010 Introductory Pasewark & Pasewark.
1 Access Lesson 3 Creating Queries Microsoft Office 2010 Introductory.
Chapter 3 Maintaining a Database
Concepts of Database Management, Fifth Edition
Database Applications – Microsoft Access Lesson 9 Designing Special Queries Updated 4/11.
Chapter 3 Single-Table Queries
Database Applications – Microsoft Access Lesson 9 Designing Special Queries.
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall1 Exploring Microsoft Office Access Committed to Shaping the Next Generation.
CS&E 1111 AcQueries Writing Simple Queries in Access Displaying on specific data fields Filtering data using criteria Objectives: Learn how to use the.
Microsoft Access 2010 Chapter 7 Using SQL. Change the font or font size for SQL queries Create SQL queries Include fields in SQL queries Include simple.
With Microsoft Office 2007 Introductory© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Introductory.
CS&E 1111 AcInnerJoins Inner Joins Objectives: Creating Queries with data from Multiple Tables Joining two tables using an Inner Join Referential Data.
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 4 BACKNEXTEND 4-1 LINKS TO OBJECTIVES Query Design Query Criteria Modify a Query Using OR.
1 Chapter 7 Query-By-Example by Monica Chan CS157B Professor Lee.
Database Queries. Queries Queries are questions used to retrieve information from a database. Contain criteria to specify the records and fields to be.
Analyzing Data For Effective Decision Making Chapter 3.
1 Single Table Queries. 2 Objectives  SELECT, WHERE  AND / OR / NOT conditions  Computed columns  LIKE, IN, BETWEEN operators  ORDER BY, GROUP BY,
Concepts of Database Management Seventh Edition
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
 Agenda 2/20/13 o Review quiz, answer questions o Review database design exercises from 2/13 o Create relationships through “Lookup tables” o Discuss.
Querying a Database Access Project 2. 2 What is a Query?  In general, a query is a form of questioning, in a line of inquiry. A query may also refer.
SESSION 3.1 This section covers using the query window in design view to create a query and sorting & filtering data while in a datasheet view. Microsoft.
Copyright 2008 McGraw-Hill Ryerson 1 TECHNOLOGY PLUG-IN T7 PROBLEM SOLVING USING ACCESS.
Exploring Microsoft Access Chapter 6 Many-to-Many Relationships: A More Complex System.
Performing Calculations—1 of 2 In addition to using queries to retrieve, update, sort, and filter data in a database, you can use a query to perform calculations.
Pasewark & Pasewark 1 Access Lesson 3 Creating Queries Microsoft Office 2007: Introductory.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
McGraw-Hill/Irwin © 2008 The McGraw-Hill Companies, All Rights Reserved Plug-In T7: Problem Solving Using Access 2007 Business Driven Technology.
Database Applications – Microsoft Access Lesson 4 Working with Queries 36 Slides in Presentation.
Reports and Queries Chapter 3 – Access text Reports – Page Queries – Page
What are queries? Queries are a way of searching for and compiling data from one or more tables. Running a query is like asking a detailed question of.
XP. Objectives Sort data and filter data Summarize an Excel table Insert subtotals into a range of data Outline buttons to show or hide details Create.
1 Chapter 3: Customize, Analyze, and Summarize Query Data Exploring Microsoft Office Access 2007.
Chapter 6 Creating, Sorting, and Querying a Table
You can sort Access data so you can view records in the order you want to view them, and you can filter data so you only see the records you want to see.
IS201 Agenda: 09/19  Modify contents of the database.  Discuss queries: Turning data stored in a database into information for decision making.  Create.
T7-1 LEARNING OUTCOMES – ACCESS PROBLEM SOLVING 1.Describe the process of using the Simple Query Wizard using Access 2.Describe the process of using the.
Week 3 Lab1 Review on Database Dina A. Said
XP New Perspectives on Microsoft Access 2002 Tutorial 31 Microsoft Access 2002 Tutorial 3 – Querying a Database.
Access Queries Agenda 6/16/14 Review Access Project Part 1, answer questions Discuss queries: Turning data stored in a database into information for decision.
Microsoft Access Lesson 5 Lexington Technology Center February 25, 2003 Bob Herring On the Web at
 Review quiz. Answer questions.  Discuss queries: ◦ What is a query? Turning data stored in a database into information for decision making. ◦ You: Completed.
Computer Science & Engineering 2111 Sorting in Queries 1CSE 2111 Lecture-Advanced Queries.
McGraw-Hill/Irwin © 2008 The McGraw-Hill Companies, All Rights Reserved Plug-In T7: Problem Solving Using Access 2007 Business Driven Technology.
Computer Science & Engineering 2111 Inner Joins and Advanced Queries 1CSE 2111 Lecture-Advanced Queries.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
Writing Simple Queries in Access
Querying in Access Objectives: Learn how to use the Access Query Design Tool manipulate data in Access: Sorting data Aggregating Data Performing Calculations.
Tutorial 5: Working with Excel Tables, PivotTables, and PivotCharts
Inner Joins Objectives: Creating Queries with data from Multiple Tables Joining two tables using an Inner Join Referential Data Integrity Cascade Update.
Plug-In T7: Problem Solving Using Access 2007
Larry Reaves October 9, 2013 Day 16: Access Chapter 2 Larry Reaves October 9, 2013.
Review of Main Database Features
Microsoft Access 2003 Illustrated Complete
GO! with Microsoft® Access e
Tutorial 3 – Querying a Database
Access: Queries III Participation Project
Presentation transcript:

CS&E 1111 AcQueries Querying in Access Sorting data Aggregating Data Performing Calculations Objectives: Learn how to use the Access Query Design Tool manipulate data in Access:

CS&E 1111 AcQueries Querying : The process of asking the database for specific information l Thus far we have written queries that can show part of data tables by displaying only specific records and fields. These are known as Select Queries. l Relational & Boolean operators in criteria l Use of wildcards l In addition to selecting specific information, queries can be used to manipulate data – sorting and aggregating information, and performing calculations.

CS&E 1111 AcQueries Foreign Key Primary Key Products: Suppliers: Consider the following database :

CS&E 1111 AcQueries Sorting Tables in a Query Use the Sorting line - Ascending or Descending to sort the resulting Query Table l To sort multiple fields – The computer will apply sort precedence for sorting fields listed on query from left to right. l Sorting can be combined with any of the filtering techniques (criteria) we have already discussed.

CS&E 1111 AcQueries List the product name, category, supplier id and units in stock for all products. The list should be ordered by units in stock - largest quantity first, and then by SupplierID. Products CategoryID ProductName Unitsinstock SupplierID ProductID Price Major Sort Minor Sort

CS&E 1111 AcQueries The “major” sort is placed to the left of the “minor” sorts in the design view Major sort Units in Stock Minor sort Supplier ID Major sort Supplier ID Minor sort Units in Stock Here First the units in stock field is sorted Here First the supplier id field is sorted

CS&E 1111 AcQueries To Aggregate fields in a Query use the Group by feature Use the Group by feature to summarize a field – calculating its average, min, max, sum etc. l Select the group(s) you wish to aggregate - Access will automatically group by the lowest detail level field. l In the desired field(s) select the function (sum, average, etc) using the pull down menu Group by SumAvgMinMaxCountStDevVarFirstLastExpressionWhere

CS&E 1111 AcQueries Write a query to summarize by category the number of different types of products and the total units in stock Products CategoryID ProductName Unitsinstock SupplierID ProductID

CS&E 1111 AcQueries The resulting dynaset: Notice the new name given to the field’s for Sum and Count Can we include Product name in this query? How could we get the average number of units in stock for products by category?

CS&E 1111 AcQueries Query design grid's Total Row options: Group By: Define the groups you want to perform the calculations for. Aggregate Functions: Sum, Avg, Min, Max etc. Where: Specify criteria for a field, so only those records that meet this criteria will be included in the aggregates. For example specify total units in stock by category for only supplier #1. Expression: Use if a calculated field is required in the query. Expressions will be calculated AFTER the fields are aggregated.

CS&E 1111 AcQueries Write a query to summarize by category the number of units in stock for Supplierid 1 or 2. Products CategoryID ProductName Unitsinstock SupplierID ProductID The resulting dynaset:

CS&E 1111 AcQueries Calculated Fields in Queries The Expression Builder is a feature in MS Access that can be used with a Query to build numerical or boolean expressions: l You may use any fields from existing tables or queries as part of the expression l The builder constructs the expression based on which field, values and operators you choose l Brackets enclose table and field names. Table/Query names are followed by an exclamation point. [table name]![field name ]

CS&E 1111 AcQueries The Expression Builder Write your equation here Expr1:[Product]![Unitsinstock] * [Product]![UnitPrice ] Select here from a list of tables, queries & other objects for use in expression Select here for Fields and operators

CS&E 1111 AcQueries Write a query to calculate the value of your inventory by product. Include the product name, units in stock and value. Name your query Totval. Products CategoryID ProductName Unitsinstock SupplierID ProductID Price Calculated Field If a field is already included on this QBE Grid, the table/query name would not be required to identify the field.

CS&E 1111 AcQueries If prices are increased by 10% on all items, estimate the new total value of your inventory by product Totval ProductName Unitsinstock Expr1 Here we are using the previously saved query instead of table Expr1: can be renamed to a new name. An expression can also use a value from a calculation in a previous query.

CS&E 1111 AcQueries If you do not have data entered in a field, the field is said to contain a Null value. Calculations which include a Null value will result in a Null value. Null value + 5 = Null Value A field defined as a primary key can not have a Null value. The Nz function allows you to change null values Nz ([variant], valueifnull) NZ will default to 0 if valueifnull is omitted

CS&E 1111 AcQueries A truck has just come in with 5 of every item you sell. Write a query to determine the new inventory of each item. Sort the list by number of units in stock, the most first. Products CategoryID ProductName Unitsinstock Price What is the value of this expression if units is stock is null?

CS&E 1111 AcQueries Using Queries - Summary: l Select the fields to be shown - show box checked l Select specific records by specifying criteria l AND, OR, NOT operators used to specify multiple criteria in a single field l Use Grid placement to indicate multiple criteria in multiple fields with same line for AND, using multiple criteria lines for OR l Use wildcards * and ? to further specify text criteria to contain specific text string l Sort resulting dynaset records for major/minor sorts – left to right grid placement determines sort order l Use ∑ to toggle Total row to group and aggregate l Use Expression Builder to easily enter formulas – using fields as operands.