Re: Generate a dynamic sequence within a query

Поиск
Список
Период
Сортировка
От David Kerr
Тема Re: Generate a dynamic sequence within a query
Дата
Msg-id 20101021233831.GA6739@mr-paradox.net
обсуждение исходный текст
Ответ на Re: Generate a dynamic sequence within a query  (Darren Duncan <darren@darrenduncan.net>)
Ответы Re: Generate a dynamic sequence within a query  ("Daniel Verite" <daniel@manitou-mail.org>)
Список pgsql-general
On Wed, Oct 20, 2010 at 09:35:11PM -0700, Darren Duncan wrote:
- Josh Kupershmidt wrote:
- >On Wed, Oct 20, 2010 at 6:22 PM, David Kerr <dmk@mr-paradox.net> wrote:
- >>I know I've seen posts on how to do this, but i can't seem to find them.
- >>
- >>I've got a data set
- >>
- >>A, B
- >>A, C
- >>A, D
- >>[...]
- >>
- >>and so on
- >>
- >>and i'd like to be able to wite a query that would result in
- >>
- >>1,A,B
- >>2,A,C
- >>3,A,D
- >>[...]
- >>
- >>PG version is 8.3.
- >
- >If you can upgrade to 8.4, you could use the row_number() window
- >function which is perfectly suited to this task, should be as simple
- >as:
- >
- >SELECT row_number() OVER (), * FROM tablename;
-
- Yes indeed.  For a simple increment by one sequence, functions like rank()
- ... see
- http://www.postgresql.org/docs/9.0/interactive/functions-window.html ...
- are exactly what you want. -- Darren Duncan


Well, an upgrade's not on tap for a few months. Until then i'll need to
figure out somethnig else.

thanks all.

Dave

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

Предыдущее
От: ljb
Дата:
Сообщение: Re: Gripe: bytea_output default => data corruption
Следующее
От: zab08
Дата:
Сообщение: compile error in libpq program