Field note · June 22, 2025
salary_max_usd by seniority: a 162% spread
Real group means for one column across 5 segments, and what the pooled average conceals.
Breaking salary_max_usd down by seniority on data-job-postings, because the headline average is 138,807 and no segment is actually there.
lead— mean 171,459, median 190,000 (243 rows)staff— mean 152,058, median 170,500 (339 rows)senior— mean 127,309, median 144,000 (984 rows)mid— mean 95,427, median 107,250 (1,170 rows)junior— mean 65,340, median 74,000 (764 rows)
Top to bottom that is 171,459 against 65,340, a spread of 162.4%. The pooled average is 138,807.
select seniority,
count(*) as rows,
round(avg(salary_max_usd)::numeric, 2) as mean,
percentile_cont(0.5) within group (order by salary_max_usd) as median
from data_job_postings
group by 1
order by mean desc;A spread that wide means the pooled number is not a summary, it is an artefact of the mix. Change the proportion of lead rows and the overall average moves without any individual group changing at all — which is how a metric goes up while every segment goes down.
Notice the mean and median columns disagree only slightly here. 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.