Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bbGLu-0004Dz-Gh for pgsql-sql@arkaria.postgresql.org; Sun, 21 Aug 2016 00:11:02 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bbGLu-0005cc-35 for pgsql-sql@arkaria.postgresql.org; Sun, 21 Aug 2016 00:11:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bbGKv-0004SL-DU for pgsql-sql@postgresql.org; Sun, 21 Aug 2016 00:10:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bbGKs-0008GR-Gv for pgsql-sql@postgresql.org; Sun, 21 Aug 2016 00:10:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u7L09uTg009678; Sat, 20 Aug 2016 20:09:56 -0400 From: Tom Lane To: JORGE MALDONADO cc: "pgsql-sql@postgresql.org" Subject: Re: Autoincrement value in a SELECT statement In-reply-to: References: Comments: In-reply-to JORGE MALDONADO message dated "Sat, 20 Aug 2016 17:44:45 -0500" Date: Sat, 20 Aug 2016 20:09:56 -0400 Message-ID: <9677.1471738196@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org JORGE MALDONADO 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