It's a mysql question.
The table has number and frequency columns as following. Frequency is the times that the number appear.
So the numbers are 0,0,0,0,0,0,0,1,2,2,2,3. (there are seven number 0, one number 1, two number 3, three number 4 in the table)
table: Number
Number frequency
----------
0 7
1 1
2 3
3 1
Question: Now I want to return the median of all numbers as following result:
We can know the median is (0+0)/2=0, because the 6th and 7th numbers are 0.
median
0
How should I write the my sql query?