PostgreSQL, how to query the database to retrieve the percentile elements of a dataset?
You can utilize NTILE to create n quantiles:

select id, min(value)
from
 (
   select id, value, 
      ntile(10) over (order by value) as nt
   from tab
 ) as dt
group by id, nt