```
select avg(number) as median FROM (SELECT Number, @accum1:= @accum1 + Frequency AS Accum1 from NUMBERS, (select @accum1:=0) as temp ORDER BY Number ) as temp4
where accum1 = (
SELECT min(Accum) as medianin FROM (
SELECT Number, @accum:= @accum + Frequency AS Accum from NUMBERS, (select @accum:=0) as temp ORDER BY Number ) as temp3
WHERE Accum >=
(
SELECT floor((sum(frequency)+1)/2) AS middle FROM Numbers
)
)
OR accum1 = (
SELECT min(Accum2) as medianin FROM (
SELECT Number, @accum2:= @accum2 + Frequency AS Accum2 from NUMBERS, (select @accum2:=0) as temp ORDER BY Number ) as tempP
WHERE Accum2 >=
(
SELECT floor((sum(frequency)+2)/2) AS middle FROM Numbers
)
)
```