Technical skill practice
SQL Average: Check the Denominator Before Comparing Rates
AVG calculates the mean of present values. Averaging percentages gives each percentage equal weight. That is different from calculating a single rate from the combined numerator and denominator.
The practice task
Compare the average of two fictional team resolution rates with the overall resolution rate. One team handled 100 enquiries and resolved 90; the other handled one and resolved none.
The data below is fictional. Run the example in a new SQLite database. It was checked with SQLite 3.51.0; other databases may use different syntax, functions or type rules.
Complete worked query
Create the small fixture and run the query together. The IDs, boundary values and missing entries make the result small enough to check by hand.
CREATE TABLE teams(name TEXT, enquiries INTEGER, resolved INTEGER);
INSERT INTO teams VALUES ('North',100,90),('South',1,0);
SELECT ROUND(AVG(100.0 * resolved / enquiries),2) AS mean_team_pct,
ROUND(100.0 * SUM(resolved) / SUM(enquiries),2) AS overall_pct
FROM teams;Checked result
This is the result of the exact example above. NULL marks a missing database value rather than the text string "NULL".
Result rows
mean_team_pct | overall_pct
45.0 | 89.11
Read the result
The two individual rates are 90 percent and zero percent. Their unweighted mean is 45 percent. Across all enquiries, 90 of 101 were resolved, producing an overall rate of approximately 89.11 percent.
Neither result is automatically wrong. The mean treats the two teams equally; the combined rate treats each enquiry equally. A report must state which unit receives equal weight so a reader does not mistake one measure for the other.
The fixture uses positive denominators. A zero or missing enquiry count needs its own policy before calculating team rates. Do not silently replace an unknown rate with zero, since that changes the mean and implies evidence the dataset may not contain.
Mistakes to check
Use these checks when adapting the example to a different dataset.
- State whether the unit being averaged is a team, person, event or period.
- Do not round each intermediate rate more than the task requires.
- Keep the combined numerator and denominator available for a weighted calculation.
Questions, answered
Can I run this example as written?
Yes, in a new SQLite database using the schema and values shown. The result above was checked with SQLite 3.51.0. Keep it separate from an existing database.
What would happen if each team handled exactly the same number of enquiries?
With equal positive denominators, the mean of the team rates and the combined rate coincide. The difference in this example comes from assigning equal weight to teams with very different enquiry counts.
Sources and examples
ResumizeAI team. Examples are fictional teaching material, not customer results. Replace sample details with your own facts.
Your experience. A complete resume.
Build in Resumize with ATS-friendly templates, guided editing and a live preview. Start free, then upgrade when you need more.
Free account required. Free-plan PDF exports include a watermark.