Re: enumerating rows

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Kovacs Zoltan <kovacsz(at)pc10(dot)radnoti-szeged(dot)sulinet(dot)hu>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: enumerating rows
Date: 2001-04-12 22:40:22
Message-ID: Pine.LNX.4.30.0104130037250.1148-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmx(dot)net http://yi.org/peter-e/

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-04-13 03:03:29 Re: Update
Previous Message Joel Burton 2001-04-12 21:23:56 Re: DROP TABLE in transaction