|
Counting records
EXAMPLE DATABASE: NhanesDATA INPUTTable nhanes in the database Nhanes.mdb is used as input to the query.
QUERY count_recordsSELECT ethn, sex, COUNT(height) AS height_observation,
COUNT(weight) AS weight_observation,
COUNT(*) AS total_observations
FROM nhanes
GROUP BY ethn, sex
ORDER BY ethn, sex;
The query count_records lists the number of height and weight observations, and the total number of observations per ethnicity and sex.
DISCUSSIONThe query counts the number of height and weight records using the COUNT( ) function. It excludes all the NULL records. Count function aggregates the result by ethnicity and sex. The statement count(*) returns all the records that is included in the nhanes table.
Last modified September 23, 2008 7:23 am
|