Select nth percentile from MySQL
Posted
by mazin k.
on Stack Overflow
See other posts from Stack Overflow
or by mazin k.
Published on 2010-06-17T21:39:57Z
Indexed on
2010/06/17
21:43 UTC
Read the original article
Hit count: 288
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 the number of rows and then running another query that sorts and selects the nth row:
select count(*) as `total` from mydata;
select * from mydata order by `field` asc limit 37,1;
Can I combine these two queries into a single query?
© Stack Overflow or respective owner