Topic 12 Lesson 2 – Retrieving Data with Queries

Slides:



Advertisements
Similar presentations
Microsoft® Office Access® 2007 Training
Advertisements

Querying a Database Microsoft Office Access 2003.
Build a database IV: Create queries for a new Access database Overview: Ask your data — create queries It’s time to create queries, one of the most powerful.
Microsoft Access 2007 Microsoft Access 2007 Introduction to Database Programs.
DATA, DATABASES, AND QUERIES Managing Data in Relational Databases CS1100Microsoft Access - Introduction1.
DATA, DATABASES, AND QUERIES Managing Data in Relational Databases CS1100Microsoft Access - Introduction1 Created By Martin Schedlbauer
1 Access Lesson 3 Creating Queries Microsoft Office 2010 Introductory Pasewark & Pasewark.
1 Access Lesson 3 Creating Queries Microsoft Office 2010 Introductory.
Food Recall System Pre Code System Design Layout Version 1.0.
Chapter 2 Querying a Database MICROSOFT ACCESS 2010.
You can use a query to view a subset of your data or to answer questions about your data. For example, if you want to view a list of student names and.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Examining.
Lesson 2.  To help ensure accurate data, rules that check entries against specified values can be applied to a field. A validation rule is applied to.
® Microsoft Office 2010 Access Tutorial 3 Maintaining and Querying a Database.
1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 8 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 8 Creating.
CS1100: Microsoft Access Managing Data in Relational Databases Created By Martin Schedlbauer CS11001Microsoft Access - Introduction.
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.
1 Database Systems Introduction to Microsoft Access Part 2.
Course ILT Forms and queries Unit objectives Create forms by using AutoForm and the Form Wizard, and add or modify form headers and footers Open and enter.
® Microsoft Office 2013 Access Maintaining and Querying a Database.
Access Forms and Queries. Entering Data in Your Table  You can add data to your table in Datasheet view, by typing in the columns and rows.  This.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. Adding a new field 1Right click the table name and select design view 2Type the field information at the end.
Pasewark & Pasewark 1 Access Lesson 3 Creating Queries Microsoft Office 2007: Introductory.
1 After completing this lesson, you will be able to: Create and run a query. Specify criteria in a query. Create a calculated field. Create a multiple-table.
1 Access Lesson 3 Creating Queries. 2 Creating a Query with the Simple Query Wizard Query-- database object that lets you ask the database about the data.
INTRODUCTION TO DATABASES USING MICROSOFT ACCESS Basic Database Terms Create A Database Creating Table Fields Populating a Table Modifying Data Create.
Microsoft Access Lesson 5 Lexington Technology Center February 25, 2003 Bob Herring On the Web at
QUERY CONSTRUCTION CS1100: Data, Databases, and Queries CS1100Microsoft Access1.
Lesson 4: Querying a Database. 2 Learning Objectives After studying this lesson, you will be able to:  Create, save, and run select queries  Set query.
Access Queries and Forms. Adding a New Field  To insert a field after you have saved your table, open Access, and open the table  It is easier to add.
ACCESS LESSON 1 DATABASE BASICS VOCABULARY. BACKSTAGE VIEW A menu of options and commands that allows you to access various screens to perform common.
Database (Microsoft Access). Database A database is an organized collection of related data about a specific topic or purpose. Examples of databases include:
1 Access Lesson 2 Creating Queries, Forms, and Reports Microsoft Office 2010 Fundamentals Story / Walls.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 1 Creating and Using a Database.
Microsoft Office Access 2010 Lab 3
Database Essentials Access Lesson 1.
Maintaining a Database Using the Design and Update Features of Access
Access Maintaining and Querying a Database
Microsoft Access 2013 Bobby Wan.
Microsoft Access – Tutorial 3
Objectives Create an action query to create a table
Database Essentials Access Lesson 1.
Performing Mail Merges
Creating and Using a Database
Microsoft Access 2003 Illustrated Complete
Access Maintaining and Querying a Database
Databases and Information Management
Microsoft Office Access 2003
Database Queries.
Creating and Modifying Queries
Database Fundamentals
Microsoft Office Access 2003
Lessons Vocabulary Access 2016.
Databases and Information Management
Introduction to Database Programs
Access: Access Basics Participation Project
Chapter 1 Databases and Database Objects: An Introduction
Access: Queries I Participation Project
Topic 12 Lesson 1 – Data and databases
Topic 15 Lesson 1 – Action queries
Building Queries using the Principle of Simplest Query (POSQ)
Introduction to Database Programs
Topic 11 Lesson 1 - Analyzing Data in Access
Joins and other advanced Queries
Creating a simple query in the Design View
Shelly Cashman: Microsoft Access 2016
Microsoft Access Date.
Nagendra Vemulapalli Access chapters 1&2 Nagendra Vemulapalli
New Perspectives on Microsoft
Presentation transcript:

Topic 12 Lesson 2 – Retrieving Data with Queries

Retrieving Data with Queries Data is retrieved through queries. Queries are formulated in a specialized language called SQL (pronounced SEQUEL). Microsoft Access makes it easy to create SQL queries through a simple drag-and-drop interface called the Query Builder. Queries are eventually integrated into reports, forms, programs, or executed by themselves. Retrieving Data with Queries

Retrieving Data with Queries Queries on Tables Queries retrieve data from one or more tables. You can specify which rows to include in the result through filters columns to include in the results The result of a query is a table that can be used in other queries (as subqueries). Retrieving Data with Queries

Creating Queries in Access To create a query: Select the Create tab Pick Query Design Select the tables to include in the query or simply close the dialog and drag the needed tables into the query designer Retrieving Data with Queries

Retrieving Data with Queries Running a Query To run a query, click on the Run icon: To return to the query design, click on ‘View’ and Select “Design View” from the Menu: Retrieving Data with Queries

Retrieving Data with Queries Example: Simple Query Find the contact id, first name, and last name for each contact. Query in Design View Query in Datasheet View Retrieving Data with Queries

Retrieving Data with Queries Removing Duplicates Query results often contain duplicate rows. These are removed by “grouping rows” with the same value as a single row. To do a Group By, follow these steps: Select the function button in the ribbon Select “Group By” for each field Retrieving Data with Queries

Retrieving Data with Queries Example: Group By Find the dates on which orders were placed. Here’s the result without a Group By: Note the duplicate rows - one row per order Retrieving Data with Queries

Retrieving Data with Queries Example: Group By Here’s the same query with a Group By: Note that the duplicate rows have been “collapsed” into groups and only the group is displayed One result set record per day as oppose to order Retrieving Data with Queries

Removing Duplicates with “Group By” Group By collapses all rows that contain the same data across all columns. OrderIDs are not the same in this example so names will show up more than once even if using Group By. Retrieving Data with Queries

Removing Duplicates with “Unique Values” Duplicates can be eliminated by specifying that the query should only return unique values. Retrieving Data with Queries

Retrieving Data with Queries Joining Tables A “JOIN” is a query operation that allows you to select data from multiple tables Rows are selected from the tables where the rows have a common value in the relationship fields. To find contacts that actually placed an order1, the ContactID column value must be the same in the Contacts and the Orders table. This essentially finds all contacts who placed at least one order. 1 There may be contacts in the Contacts table that are not linked to any order, i.e., they never placed an order. Retrieving Data with Queries

Retrieving Data with Queries Example: Join Find the first name, last name, and zip code of all contacts that placed an order. JOIN occurs across ContactID (relationship line) Here’s the result without a Group By: Note the duplicate rows – one row for each order as oppose to contact Retrieving Data with Queries

Example: Group By and Join Find the first name, last name, and zip code of all contacts that placed an order. Here’s the result with a Group By: All rows with the same first name, last name, and zip code have been collapsed into a single “group”, one row per contact. Retrieving Data with Queries

Retrieving Data with Queries Filtering Selecting rows that meet a certain criteria. Lists all of the line items (ID only) that have a Quantity > 2. Retrieving Data with Queries

Retrieving Data with Queries Selection Criteria Selection criteria are specified as an algebraic relationship, but queries are generally stated as a narrative, so we need to “translate”. Narrative Algebraic Term At least X >= X No more than X < X More than X > X No less than X Less than X Up to X At most X <= X Retrieving Data with Queries

Registrar Example Database Relationships Data Queries Student names, address, city, state, zip Courses with 4 or more credits Students in CS2500 Students in CS1100 Retrieving Data with Queries

Retrieving Data with Queries Questions? Retrieving Data with Queries