I want to calculate the percentile in MYSQL. Please let me know this is the right way to calculate the percentile.
Set @percentile = 30;
select firnum, a.rownum
from
(select firnum, @rownum := @rownum + 1 AS rownum
from (select firnum from per order by firnum) as a,
(SELECT @rownum := 0) b) as a,
(select round((COUNT(*) * @percentile)/100) percen from per) as b
where a.rownum = b.percen;