Re: row numbering

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: row numbering
Дата
Msg-id 874qfzq3od.fsf@stark.xeocode.com
обсуждение исходный текст
Ответ на row numbering  (josue <josue@lamundial.hn>)
Список pgsql-general
josue <josue@lamundial.hn> writes:

> to something like:
>
> select counter(),a,b from foo;

The OLAP SQL Standard way to spell this is "ROW_NUMBER() OVER ()".

Postgres doesn't have any support for any of the OLAP features however. It
would be really nice because they're nigh impossible to emulate with standard
SQL.

You might be able to get away with a sequence, but if you have multiple
connections running this query at the same time then that will be awkward. You
would have to create a new sequence for the query every time.

If you can you're probably best off doing this in the client. You can do any
sort of level break logic you need in the client, and even refer to previous
records. The only thing that would make doing it in the client awkward would
be if you were planning to use the results in more query logic such as a join.

--
greg

В списке pgsql-general по дате отправления:

Предыдущее
От: Rick Apichairuk
Дата:
Сообщение: Re: Newbie: help with FUNCTION
Следующее
От: Greg Stark
Дата:
Сообщение: Re: Hash aggregates blowing out memory