Field note · June 25, 2023
The overall average hides 4 different numbers
Real group means for one column across 4 segments, and what the pooled average conceals.
region splits saas-subscriptions into 4 groups. Here is what seats looks like inside each.
LATAM— mean 56, median 10 (167 rows)EMEA— mean 53, median 9 (744 rows)AMER— mean 50, median 8 (1,162 rows)APAC— mean 46, median 7 (427 rows)
Top to bottom that is 56 against 46, a spread of 22.9%. The pooled average is 51.
select region,
count(*) as rows,
round(avg(seats)::numeric, 2) as mean,
percentile_cont(0.5) within group (order by seats) as median
from saas_subscriptions
group by 1
order by mean desc;The groups are close enough that the pooled average is a fair summary. That is worth confirming rather than assuming: the check costs one query and the failure mode is invisible.
Notice the mean and median columns disagree most in LATAM, where the mean sits well above the median. Always compute both in the group-by. The comparison between them per segment is free and tells you whether you are looking at a level difference or a tail difference.
This is the setup for Simpson's paradox — the case where every segment moves one way and the total moves the other.