Re: Selecting top N percent of records.

Поиск
Список
Период
Сортировка
Искать
От
Tim Uckun
Тема
Re: Selecting top N percent of records.
Дата
Msg-id
AANLkTimBXwCheGaet+qKdZ_xGJxOUe4zs6KMRMBYeEps@mail.gmail.com
Ответ на
Список
Дерево обсуждения
Selecting top N percent of records. Tim Uckun <timuckun@gmail.com>
Re: Selecting top N percent of records. Darren Duncan <darren@darrenduncan.net>
Re: Selecting top N percent of records. Tim Uckun <timuckun@gmail.com>
Re: Selecting top N percent of records. Peter Geoghegan <peter.geoghegan86@gmail.com>
Re: Selecting top N percent of records. Tim Uckun <timuckun@gmail.com>
Re: Selecting top N percent of records. Craig Ringer <craig@postnewspapers.com.au>
Re: Selecting top N percent of records. Tim Uckun <timuckun@gmail.com>
> That is a bit problematic because it necessitates knowing the number
> of rows total, and slow counting is an idiosyncrasy of postgres.
>
> http://wiki.postgresql.org/wiki/Slow_Counting
>
> To get the top 10%:
>
> SELECT * FROM table LIMIT(SELECT (COUNT(*) * 0.1)::integer FROM table)


I think I wasn't making myself clear. I don't want the top 10% of the
rows. I want the rows with the top 10% of the values in a column.

In my case there is a very non linear set of values. The lowest value
is 1 and the vast majority of records have a 1 in the column. The
highest value might be in the tens of thousands.  I want to pull up
the records that have the top ten percent values.
В списке pgsql-general по дате отправления
От: Tim Uckun
Дата:
От: Craig Ringer
Дата:
FAQ