How can I calculate the median of values in SQLite?
Let’s say that the median is the element in the middle of an ordered list. SQLite (4 or 3) does not have any built-in function for that, but it’s possible to do this by hand: SELECT x FROM MyTable ORDER BY x LIMIT 1 OFFSET (SELECT COUNT(*) FROM MyTable) / 2 When there is an … Read more