fbpx

Find a Median in Tables - Robert's Blog

Find a Median in Tables

By Robby 0 Comment July 13, 2016

The simplest query to find the Median

SELECT x.val from table x, table y GROUP BY x.val HAVING SUM(SIGN(1-SIGN(y.val-x.val))) = (COUNT(*) +1)/2

Add Comment

Your email address will not be published. Required fields are marked *