Field note · September 30, 2026
The overall average hides 8 different numbers
Real group means for one column across 8 segments, and what the pooled average conceals.
country splits retail-orders into 8 groups. Here is what unit_price_usd looks like inside each.
FR— mean 76.34, median 50.28 (522 rows)AU— mean 73.87, median 51.03 (501 rows)JP— mean 73.07, median 49.67 (587 rows)BR— mean 72.86, median 47.15 (367 rows)GB— mean 72.85, median 47.85 (915 rows)DE— mean 72.80, median 49.06 (738 rows)
Top to bottom that is 76.34 against 71.66, a spread of 6.5%. The pooled average is 72.66.
select country,
count(*) as rows,
round(avg(unit_price_usd)::numeric, 2) as mean,
percentile_cont(0.5) within group (order by unit_price_usd) as median
from retail_orders
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 FR, 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.