how to get an element from the middle of a table in my sql code example
Example: how to get an element from the middle of a table in my sql
SET @rowindex := -1;
SELECT
AVG(d.distance) as Median
FROM
(SELECT @rowindex:=@rowindex + 1 AS rowindex,
demo.distance AS distance
FROM demo
ORDER BY demo.distance) AS d
WHERE
d.rowindex IN (FLOOR(@rowindex / 2), CEIL(@rowindex / 2));