Upload
myrtle-gaines
View
233
Download
0
Embed Size (px)
DESCRIPTION
CALCULATIONS IN QUERY Queries can be built to perform a calculation as part of the query We often do this for things that we do not need to store and take up space with Expressions can be entered into the query design grid as if they were regular fields Done on Numeric data type fields
Citation preview
ACCESS 3
OBJECTIVES
• Calculated fields in query design• Total option in query design• Creating Forms
CALCULATIONS IN QUERY• Queries can be built to perform a
calculation as part of the query• We often do this for things that we do not
need to store and take up space with• Expressions can be entered into the query
design grid as if they were regular fields• Done on Numeric data type fields
• To perform a calculation in a query, you must add a calculated field to the query design.
• Make certain that you are following the rules of precedence !
• Two options for entering expressions: – Enter the expression directly into the field text
box– Enter the expression in the Expression
Builder
CREATING A CALCULATED FIELD USING BUILDERRemove the existing criteria In design view, click in the place where
you want calculated field.Then click the magic wand “Builder” icon
above. The expression builder shows up…
THE EXPRESSION BUILDER…
REMEMBER THIS…
• Note: If you see <<expr>> be sure to remove it ! ! !
• Expand the width of the column if you see ####…
EXAMPLE
• In Design View of Query2 let us create a calculated field to show employment percent
EmpRate\(EmpRate+UnEmpRate)
GET APPROPRIATE FIELDS IN TO BUILDER
FORMAT
• Format the calculated field as Fixed number with 4 decimal places
• Execute the query
SORT
• Sort GDP in ascending order
EXAMPLE 2
• Download Baseball_Statistics file
QUERY• Create a query to display League name
and Team name
NOTICE REPETITIONS
GROUP BY USING TOTALS
SELECT THE APPROPRIATE GROUP BY OPTION
• Group by Leagues and number of teams
NOTICE THE QUERY RESULT
OTHER GROUP BY OPTIONS
• Average• Sum• Minimum• Maximum
CREATE A FORM WITH SUBFORM
The main form should display the name of each league and division in the Divisions table
SELECT FIELD FOR MAIN FORM
SELECT FIELDS FOR SUBFORM
The subform should display the individual team names, the percent of games won, and whether they participated in a playoff game
NOTICE FROM WITH SUBFORM(S)
DATASHEET LAYOUT
TITLES
• Main form as League Results • Subform as League Results Subform