Re: Autoincrement value in a SELECT statement

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Autoincrement value in a SELECT statement
Date: 2016-08-21 00:09:56
Message-ID: 9677.1471738196@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

JORGE MALDONADO <jorgemal1960(at)gmail(dot)com> writes:
> Is it possible to include a field in the SELECT statement which "kind of
> autoincrements" so I can get the position?

The row_number() window function should do that for you, or you might
want rank() depending on what you think should happen for ties.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message CN 2016-08-23 16:13:35 Display group title only at the first record within each group
Previous Message JORGE MALDONADO 2016-08-20 22:44:45 Autoincrement value in a SELECT statement