Select nth percentile from MySQL

后端 未结 3 396
情话喂你
情话喂你 2021-01-19 18:43

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

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-19 19:38

    There's also this solution, which uses a monster string made by GROUP_CONCAT. I had to up the max on the output like so to get it to work:

    SET SESSION group_concat_max_len = 1000000;
    

    MySql wizards out there: feel free to comment on the relative performance of the methods.

提交回复
热议问题