Re: serial in output - Mailing list pgsql-sql

From Harald Fuchs
Subject Re: serial in output
Date
Msg-id 87mzkk4iju.fsf@srv.protecting.net
Whole thread Raw
In response to serial in output  ("alessandra de gregorio" <adegregorio@fgscapital.com>)
List pgsql-sql
In article <20051028111824.C8C7DDA53F@svr1.postgresql.org>,
"alessandra de gregorio" <adegregorio@fgscapital.com> writes:

> Hi,
> What function should I use to get a serial number, together with my results,
> from a query?

> Ex. Of output I want:

> 1    ooo    pp    ij
> 2    hou    joo    iu    
> 3    bhi    ft    yh

> Basically, I would like to have one column with integers, from 1 onwards, no
> matter how many tables I join in, or the data that I get back.

I'd do it in application code, but if you insist on doing it at the
SQL layer:

CREATE TEMPORARY SEQUENCE tmpseq;
SELECT nextval('tmpseq'), othercols... FROM ...



pgsql-sql by date:

Previous
From: Andreas Kretschmer
Date:
Subject: Re: serial in output
Next
From: James Robinson
Date:
Subject: Re: Design question: Scalability and tens of thousands of tables?