X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B6A4FD97FD for ; Fri, 4 Nov 2005 13:15:16 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81639-02 for ; Fri, 4 Nov 2005 17:15:13 +0000 (GMT) X-Greylist: delayed 03:07:24.817449 by SQLgrey- Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) by svr1.postgresql.org (Postfix) with ESMTP id 5AF13D964A for ; Fri, 4 Nov 2005 13:15:12 -0400 (AST) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by svr2.postgresql.org (Postfix) with ESMTP id 6C742F12DA for ; Fri, 4 Nov 2005 14:07:53 +0000 (GMT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1EY2Bs-0000nE-2k for pgsql-sql@postgresql.org; Fri, 04 Nov 2005 15:05:12 +0100 Received: from srv.protecting.net ([212.126.218.242]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 04 Nov 2005 15:05:12 +0100 Received: from hf0923x by srv.protecting.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 04 Nov 2005 15:05:12 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Harald Fuchs Subject: Re: serial in output Date: 04 Nov 2005 15:03:01 +0100 Organization: Linux Private Site Lines: 21 Message-ID: <87mzkk4iju.fsf@srv.protecting.net> References: <20051028111824.C8C7DDA53F@svr1.postgresql.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: srv.protecting.net User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.005 required=5 tests=[AWL=0.005] X-Spam-Score: 0.005 X-Spam-Level: X-Archive-Number: 200511/56 X-Sequence-Number: 23307 In article <20051028111824.C8C7DDA53F@svr1.postgresql.org>, "alessandra de gregorio" writes: > Hi, > What function should I use to get a serial number, together with my results, > from a query? > Ex. Of output I want: > 1 ooo pp ij > 2 hou joo iu > 3 bhi ft yh > Basically, I would like to have one column with integers, from 1 onwards, no > matter how many tables I join in, or the data that I get back. I'd do it in application code, but if you insist on doing it at the SQL layer: CREATE TEMPORARY SEQUENCE tmpseq; SELECT nextval('tmpseq'), othercols... FROM ...