From: | Harald Fuchs <hf0923x(at)protecting(dot)net> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: serial in output |
Date: | 2005-11-04 14:03:01 |
Message-ID: | 87mzkk4iju.fsf@srv.protecting.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
In article <20051028111824(dot)C8C7DDA53F(at)svr1(dot)postgresql(dot)org>,
"alessandra de gregorio" <adegregorio(at)fgscapital(dot)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 ...
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-11-04 14:47:58 | Re: Changing location of ORDER BY has large effect on performance, but not results... |
Previous Message | Andreas Kretschmer | 2005-11-04 12:48:52 | Re: serial in output |