Re: enumerating rows - Mailing list pgsql-sql

From Peter Eisentraut
Subject Re: enumerating rows
Date
Msg-id Pine.LNX.4.30.0104130037250.1148-100000@peter.localdomain
Whole thread Raw
In response to enumerating rows  (Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>)
List pgsql-sql
Kovacs Zoltan writes:

> Maybe a trivial question, maybe it's foreign from SQL, I'dont know...
> How to add a column which stands for the row number in each row of the
> result? E.g.:
>
> row_no | column1 | column2 | ...
> -------+---------+---------+ ...
>      1 | datum11 | datum12 | ...
>      2 | datum21 | datum22 | ...
>    ... |     ... |     ... | ...
>
> I didn't find anything in the docs.

Your client can do that.  When you fetch the results you have to have some
sort of loop anyway, so you have (or keep) a counter there.  There's no
use of the server generating this information, because the numbering is
implied by the order in which the rows are sent.

-- 
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/



pgsql-sql by date:

Previous
From: Joel Burton
Date:
Subject: Re: DROP TABLE in transaction
Next
From: Tom Lane
Date:
Subject: Re: Update