queries
TRANSCRIPT
QueriesCIS-145
Select QueriesMethod to find, organize, summarize data
& create informationUses data from tables, other queriesCan include calculations
Design View
Identify where to get dataSpecify which rows to use Identify fields, calculations to returnHow to order the results
Datasheet View
“Dynaset” is the result of a query“Dynamic subset”
Saving a query saves the “question” not the answer
Select Query Design View
Table
Run Button
Criteria
Select Query Dynaset
The results of the queryare displayed as a dynaset
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
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
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
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
Query CriteriaWhich rows should be included?Criteria are True/False
conditions/comparisonsConditions can use:
Relational operators (=, >, <, <=, >=, <>)
BetweenLike (patterns, Wild cards)
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
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
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
SortingQuery results can be sortedAccess works from left to right when
sorting if multiple fields are sorted