I use PostgreSQL and have records like this on groups of people:
name | people | indicator
--------+--------+-----------
group 1 | 1000 | 1
group 2 | 100
Find the first cumulative sum of people greater than the median of total sum:
with the_data(name, people, indicator) as (
values
('group 1', 1000, 1),
('group 2', 100, 2),
('group 3', 2000, 3)
)
select name, people, indicator
from (
select *, sum(people) over (order by name)
from the_data
cross join (select sum(people)/2 median from the_data) s
) s
where sum > median
order by name
limit 1;
name | people | indicator
---------+--------+-----------
group 3 | 2000 | 3
(1 row)