public class AgesDataBean extends Object
AGE_VIEW
, AGE_TO_BIRTH_YEAR_VIEW
, and AGE_TO_DEATH_YEAR_VIEW
. The latter two views actually reference the first view.
The select statement for these views are defined as follows:
AGE_VIEW
SELECT B.PERSON_ID, (D.YEAR-B.YEAR) AS AGE, B.YEAR AS BIRTH_YEAR, D.YEAR AS DEATH_YEAR FROM EVENT B,EVENT D WHERE B.PERSON_ID=D.PERSON_ID AND B.TYPE='birth' AND D.TYPE='death' AND B.YEAR IS NOT NULL AND D.YEAR IS NOT NULL;
AGE_TO_BIRTH_YEAR_VIEW
SELECT AVG(AGE) AVG_AGE, MEDIAN(AGE) MEDIAN_AGE, BIRTH_YEAR FROM AGE_VIEW GROUP BY BIRTH_YEAR ORDER BY BIRTH_YEAR;
AGE_TO_DEATH_YEAR_VIEW
SELECT AVG(AGE) AVG_AGE, MEDIAN(AGE) MEDIAN_AGE, DEATH_YEAR FROM AGE_VIEW GROUP BY DEATH_YEAR ORDER BY DEATH_YEAR;
Constructor and Description |
---|
AgesDataBean() |
Modifier and Type | Method and Description |
---|---|
int |
ageQuartile(int quartile)
Returns the specified age quartile.
|
Map<String,Integer> |
ages()
Returns a map of ages to number of people who lived to be that age.
|
double |
averageAge()
Returns the average age in the database.
|
int |
maxAge()
Returns the maximum age in the database.
|
Map<String,Integer[]> |
meanMeadianAgesPerBirthYear()
Returns a map of years to the mean and median ages of people who where born that year.
|
Map<String,Integer[]> |
meanMeadianAgesPerDeathYear()
Returns a map of years to the mean and median ages of people who died that year.
|
double |
medianAge()
Returns the median age in the database.
|
int |
minAge()
Returns the minimum age in the database.
|
public double averageAge()
AVG()
function,
and only accounts for those ages that can be calculated, i.e. ages of persons that have both a known birth and
death date.public double medianAge()
MEDIAN()
function,
and only accounts for those ages that can be calculated, i.e. ages of persons that have both a known birth and
death date.public int minAge()
MIN()
function,
and only accounts for those ages that can be calculated, i.e. ages of persons that have both a known birth and
death date.public int maxAge()
MAX()
function,
and only accounts for those ages that can be calculated, i.e. ages of persons that have both a known birth and
death date.public int ageQuartile(int quartile)
SELECT AGE, NTILE(4) OVER (ORDER BY AGE) AS QUARTILE FROM AGE_VIEW
) to assign each value to
a quartile, then selects the maximum value from the specified quartile.
This method only accounts for those ages that can be calculated, i.e. ages of persons that have both a known birth and death date.
quartile
- an integer, which should range from 1 to 4.IllegalArgumentException
- if the quartile is less than 1 or greater than 4public Map<String,Integer> ages()
LinkedHashMap
.
The ages are recorded as a String
while the count of people is recorded as a Integer
.
This method only accounts for those ages that can be calculated, i.e. ages of persons that have both a known birth and death date.
public Map<String,Integer[]> meanMeadianAgesPerBirthYear()
LinkedHashMap
. The year is represented by a while the mean and median is represented by an
Integer
array of length 2. The zeroth value of the array is the mean, while the last value is the
median.
This method only accounts for those ages that can be calculated, i.e. ages of persons that have both a known birth and death date.
public Map<String,Integer[]> meanMeadianAgesPerDeathYear()
LinkedHashMap
. The year is represented by a while the mean and median is represented by an Integer
array of length 2. The zeroth value of the array is the mean, while the last value is the median.
This method only accounts for those ages that can be calculated, i.e. ages of persons that have both a known birth and death date.
Copyright © 2015 Joseph Hendrix