Re: Generate a dynamic sequence within a query - Mailing list pgsql-general

From David Kerr
Subject Re: Generate a dynamic sequence within a query
Date
Msg-id 20101021150439.GA82034@mr-paradox.net
Whole thread Raw
In response to Re: Generate a dynamic sequence within a query  (Josh Kupershmidt <schmiddy@gmail.com>)
List pgsql-general
On Wed, Oct 20, 2010 at 10:32:15PM -0400, 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;

Ah, no chance of that for a while. figures all the  fun stuff is always a version
away =)

Dave

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: full vacuum cancelation
Next
From: Richard Broersma
Date:
Subject: Re: Updates, deletes and inserts are very slow. What can I do make them bearable?