X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9451DD1D105 for ; Mon, 12 Apr 2004 19:41:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 15065-05 for ; Mon, 12 Apr 2004 19:41:25 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 06966D1C50B for ; Mon, 12 Apr 2004 19:41:23 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i3CMfLT1025323 for ; Mon, 12 Apr 2004 22:41:22 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i3CMKHKe022120 for pgsql-sql@postgresql.org; Mon, 12 Apr 2004 22:20:17 GMT From: CoL X-Newsgroups: comp.databases.postgresql.sql Subject: Re: Function for numbering rows? Date: Tue, 13 Apr 2004 00:21:01 +0200 Organization: Hub.Org Networking Services Lines: 33 Message-ID: References: <272e4be7.0404100812.50a8c7fe@posting.google.com> Reply-To: col@mportal.hu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7b) Gecko/20040316 X-Accept-Language: en-us, en In-Reply-To: <272e4be7.0404100812.50a8c7fe@posting.google.com> To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/171 X-Sequence-Number: 17546 hi, Tony Reina wrote, On 4/10/2004 18:12: > Simple question: > > Is there a function that will allow me to number the returned tuples? > > e.g. > > CREATE TABLE test ( > field1 text > ): > > INSERT INTO test VALUES ('first'); > INSERT INTO test VALUES ('second'); > INSERT INTO test VALUES ('third'); > INSERT INTO test VALUES ('fourth'); > > SELECT number(), field1 FROM test; > > 1 'first' > 2 'second' > 3 'third' > 4 'fourth' > > where number() is the function I'm trying to find out about. a simple way: create temporary sequence st; select nextval('st'),field1 from test; drop sequence st; C.