'''

select avg(a.Number) as median

from(

select number, frequency,@row:=@row+0 as beg, (@row:=frequency+@row) as fin,b.total

from (select * from Numbers order by Number) c,

(select @row:=0 ) r,

(select sum(frequency) as total from Numbers) b ) a

where

case when total%2=0 then (total/2 <=a.fin and total/2 >a.beg) or ((total)/2+1 <=a.fin and (total)/2+1 >a.beg)

else (total+1)/2 <=a.fin and (total+1)/2 >a.beg

end

'''