I have a simple table of data, and I\'d like to select the row that\'s at about the 40th percentile from the query.
I can do this right now by first querying to find
As an exercise in futility (your current solition would probably be faster and prefered), if the table is MYISAM (or you can live with the approximation of InnoDB):
SET @row =0;
SELECT x.*
FROM information_schema.tables
JOIN (
SELECT @row := @row+1 as 'row',mydata.*
FROM mydata
ORDER BY field ASC
) x
ON x.row = round(information_schema.tables.table_rows * 0.4)
WHERE information_schema.tables.table_schema = database()
AND information_schema.tables.table_name = 'mydata';