Download 7_Statistical Outcomes

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Chapter 6
Statistical Outcomes
IT Key Ideas, Dynamic Database Systems, 2002
IT Key Ideas, Dynamic Database Systems, 2002
Review
page 65
A find locates a particular piece of data in
order to answer a specific question about
the one person (entity). For example, what
is Bonny Jane’s surname?
IT Key Ideas, Dynamic Database Systems, 2002
A query, eg.
how many people have brown hair?
locates many records that match the
specified criteria.
Even while there are many records,
there is nevertheless one answer.
Even if the wording is changed to
list the people have brown hair
the list is but one answer.
IT Key Ideas, Dynamic Database Systems, 2002
# records
IT Key Ideas, Dynamic Database Systems, 2002
Consider these outcomes
How many people have each colour of hair? or
How many people are there per age? or
For each favourite TV programme, list the
names of the people.
Each question will have many answers. The last
question will have many lists, i.e. many answers.
IT Key Ideas, Dynamic Database Systems, 2002
Statistical
Outcome
by using a
Query with
Total
IT Key Ideas, Dynamic Database Systems, 2002
Statistical
Outcome
Report,
with
groups
and
summaries
Statistical Outcomes
How many people have each colour of hair? or
How many people are there per age?
The critical word that leads to the production
of many answers is each or per.
IT Key Ideas, Dynamic Database Systems, 2002
Statistical outputs
are achieved by
activating Total,
which adds a new
line to the QBE
grid.
IT Key Ideas, Dynamic Database Systems, 2002
Statistical Commands
Command
Group By
Count
Where
Sum
Avg
Min
Max
First
Last
StDev
Var
Expression
page 66
Explanation
organises or sorts records into groups
counts the number of records
a specified criteria has to be met
calculates a total value (for each group)
calculates average values
determines the smallest values
determines the largest values
determines the first value
determines the last value
calculates the standard deviation
calculates the variance
to create specific calculations
page 66
Example
How many people have each different hair
colour?
To achieve this in a room
of people one would
organise groups of people
into different corners of
the room according to
their hair colour and then
manually count the
number of people in each
group.
IT Key Ideas, Dynamic Database Systems, 2002
# people each hair colour
The elements of data required to
achieve this output are
Hair Colour and Surname.
The Hair Colours are grouped and
the Surnames are counted.
Hair Colour
Surname
GroupBy
Count
IT Key Ideas, Dynamic Database Systems, 2002
Output
IT Key Ideas, Dynamic Database Systems, 2002
NB:
Different fields can be used as the
counting field, rather than Surname,
without affecting the output.
IT Key Ideas, Dynamic Database Systems, 2002
Statistical Queries
page 67
Practical 6.1
IT Key Ideas, Dynamic Database Systems, 2002
Hint
If a little unsure,
work out the
output. Make a
mock list of what
you expect the
result to look like.
Example – This week’s pay for
each employee
Sydney Daw
Mahlah Illman
Zo Treadwell
Kathleen Anderson
Desmond Fekete
Judith Offler
Jarrod Manuel
Elvin Braine
Derek Empson
Gerda Tayler
$226
$266
$263
$297
$237
$214
$212
$305
$330
$224
page 68
The number of people for each Age
The word age follows the term each, then it
is Age that needs to be placed in groups. To
determine the number of people, count the
Surnames.
Age:
Surname
GroupBy
Count
Age: Int((Date()-[Date of Birth])/365.2425)
IT Key Ideas, Dynamic Database Systems, 2002
Dates of birth of the eldest person
for each different eye colour
The grouping field is Eye Colour.
NB: Dates are stored as numbers from 1/1/11900.
The older a person is the smaller the
number stored in the Date of Birth field =>
Min is the appropriate statistical command.
IT Key Ideas, Dynamic Database Systems, 2002
Formatting
Field
Format
Date of Birth dddd, d\ mmmm\ yyyy
(amongst other variations)
Average age
Fixed, 2 decimal places
Phone number @@@@\ @@@@ (if stored as text)
IT Key Ideas, Dynamic Database Systems, 2002
Average age of males and females
The groups are the males and females,
hence GroupBy Sex.
The average age specifies the Avg
command.
IT Key Ideas, Dynamic Database Systems, 2002
The number of people for each Age
The word age follows the term each, then it
is Age that needs to be placed in groups. To
determine the number of people, count the
Surnames.
IT Key Ideas, Dynamic Database Systems, 2002
page 69
The number of people per hair colour
per eye colour
The double per indicates a double grouping.
The order of implementation of such a question is
often virtually backward; i.e.
Group By
Group By
Count
Eye Colour
Hair Colour
Surname
IT Key Ideas, Dynamic Database Systems, 2002
Statistical Outcomes with criteria
Criteria can be applied to Statistical Outcomes,
just as with standard Queries. Indeed, in a
real-life system, one is unlikely to produce
statistics of the whole set of data.
IT Key Ideas, Dynamic Database Systems, 2002
The number of people per eye colour,
who are at least 50 years of age
This query involves setting a criterion of at
least 50 for the Age field. This is accomplished
by using the Where command on the Total line.
Grouping the Eye Colour
Counting the Surnames
Where the Age is >=50
IT Key Ideas, Dynamic Database Systems, 2002
page 69
IT Key Ideas, Dynamic Database Systems, 2002
SQL, for statistical outcomes
SELECT [Eye Colour], Count (Surname) as Count
FROM Details
WHERE Int((Date()-[Date of Birth])
/365.2425)>=50
GROUP BY [Eye Colour];
page 69
The number of blonde females per age
Set Hair Colour to Blonde and
Sex to f
Grouping the Age
Counting the Surname
IT Key Ideas, Dynamic Database Systems, 2002
The number of male and female adults
with brownish hair
Set Age to >= 18 and
Hair Colour to *brown
Grouping Sex
Counting Surname
IT Key Ideas, Dynamic Database Systems, 2002
The number of people in each generation
Group By Generation
Count Surname
comes readily
to mind
But how is Generation obtained?
It is similar and connected to Age, but how
is it related?
A comparison between Ages and
Generations may help.
IT Key Ideas, Dynamic Database Systems, 2002
The number of people in each generation
Age
10
11
12
13
14
15
16
17
18
19
Generation
10s
10s
10s
10s
10s
10s
10s
10s
10s
10s
Age
20
21
22
23
24
25
26
27
28
29
Generation
20s
20s
20s
20s
20s
20s
20s
20s
20s
20s
Age
30
31
32
33
34
35
36
37
38
39
Generation
30s
30s
30s
30s
30s
30s
30s
30s
30s
30s
Age
40
41
42
43
44
45
46
47
48
49
Generation
40s
40s
40s
40s
40s
40s
40s
40s
40s
40s
IT Key Ideas, Dynamic Database Systems, 2002
The number of people in each generation
The connection between Age and Generation
is a span of ten years,
10-19 is the 10s
20-29 is the 20s and so on.
The Generations can be generated either
arithmetically or by using text functions as
the first digit is the same.
IT Key Ideas, Dynamic Database Systems, 2002
Arithmetically
Pick any age between 20 and 29,
for example 27
divide by 10
2.7
remove the decimal component
2
multiply the age by 10
20
add the s to the characters
IT Key Ideas, Dynamic Database Systems, 2002
Text based
take the first character of the age,
for example with 27
2
add the characters 0s
20s
IT Key Ideas, Dynamic Database Systems, 2002
Homework/Study
page 71-73
Exercise 6.2
table of data page 72
Data File
People&Hobbies
IT Key Ideas, Dynamic Database Systems, 2002
page 74
Data File
Practical 6.3
Class Details
IT Key Ideas, Dynamic Database Systems, 2002
Chapter 6
********************************