to select the median of the values of a field from a sqlite table SELECT field FROM mytable ORDER BY field LIMIT 1 OFFSET (SELECT COUNT(*) FROM mytable) / 2