queries

15
Queries CIS-145

Upload: randy-riness-south-puget-sound-community-college

Post on 11-Jun-2015

611 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Queries

QueriesCIS-145

Page 2: Queries

Select QueriesMethod to find, organize, summarize data

& create informationUses data from tables, other queriesCan include calculations

Page 3: Queries

Design View

Identify where to get dataSpecify which rows to use Identify fields, calculations to returnHow to order the results

Page 4: Queries

Datasheet View

“Dynaset” is the result of a query“Dynamic subset”

Saving a query saves the “question” not the answer

Page 5: Queries

Select Query Design View

Table

Run Button

Criteria

Page 6: Queries

Select Query Dynaset

The results of the queryare displayed as a dynaset

Page 7: Queries

Creating a Query1. Identify where the data is coming from2. Determine which rows are part of your

answer3. Identify any groups or summaries needed4. Specify which groups are part of the

answer5. Select the fields or calculations to

include in the result6. Apply sorting to help users understand

result

Page 8: Queries

Query Data SourcesQueries can use tables or queries as

data sourcesIf more than one table is needed for

the query result a join is requiredMake sure that there is a connection

(join) to each tableMake sure you can find common

values to connect each table

Page 9: Queries

JoinsConnect tables temporarily when query

executesAccess will create a join automatically

where tables have a relationshipJoin fields should be on fields that are the

same data type

Page 10: Queries

Types of JoinsInner Join

Default joinLooking for matching values in both tables

If a table has a value not found in the second table nothing is returned

Outer JoinAllows query to return rows that don’t have a

match in the other tableCartesian Join

Combines all rows whether match or not

Page 11: Queries

Query CriteriaWhich rows should be included?Criteria are True/False

conditions/comparisonsConditions can use:

Relational operators (=, >, <, <=, >=, <>)

BetweenLike (patterns, Wild cards)

Page 12: Queries

Wild CardsWild cards can help describe patters

? – one character in a particular space* - zero, one, or more characters

S?ND returns SAND, SENDS*ND returns SAND, SENT, STAND,

SOUND

Page 13: Queries

Logical Operators

Needed when there are multiple criteriaAND condition: all tests must be passedOR condition: as long as one test is

passed the row is includedNOT creates the inverse

If something returns True, NOT makes it False

Page 14: Queries

GroupingGrouping (“totals queries” in Access)

provides summaries about dataCan create summary values using

Aggregate functionsHow many? (Count)How much? (Sum)

Can summarize all rows or find common values to create groupsTotal Credits v. Total Credits for each

department

Page 15: Queries

SortingQuery results can be sortedAccess works from left to right when

sorting if multiple fields are sorted