agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: JORGE MALDONADO <jorgemal1960@gmail.com>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: Autoincrement value in a SELECT statement
Date: Sat, 20 Aug 2016 20:09:56 -0400
Message-ID: <9677.1471738196@sss.pgh.pa.us> (raw)
In-Reply-To: <CAAY=A78V4h_iyy-_Yq+0jDiu+GzNMXLP3adgfd=EuwZM5GyOiA@mail.gmail.com>
References: <CAAY=A78V4h_iyy-_Yq+0jDiu+GzNMXLP3adgfd=EuwZM5GyOiA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

JORGE MALDONADO <jorgemal1960@gmail.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


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (2+ messages)

Message-ID: <9677.1471738196@sss.pgh.pa.us>
Permalink:  ../9677.1471738196@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/9677.1471738196@sss.pgh.pa.us

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jorgemal1960@gmail.com
  Subject: Re: Autoincrement value in a SELECT statement
  In-Reply-To: <9677.1471738196@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox