```
set @r1=0,@r2=0;
select avg(M.Number) median
from
((select Number
from (select *, @r1:=@r1+Frequency CDF
from Numbers
order by Number) T
where CDF >= ceil((@r1+1)/2)
limit 1)
union
(select Number
from (select *, @r2:=@r2+Frequency CDF
from Numbers
order by Number) T
where CDF >= floor((@r2+1)/2)
limit 1)) M
```