Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 878DC133798E for ; Thu, 27 Jan 2011 11:21:23 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 31815-05 for ; Thu, 27 Jan 2011 15:21:16 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.techbaza.pl (techbaza-r.3s.pl [85.14.102.154]) by mail.postgresql.org (Postfix) with SMTP id 76AB71337B84 for ; Thu, 27 Jan 2011 11:21:14 -0400 (AST) Received: from [192.168.1.206] ([192.168.1.206]) by mail.techbaza.pl ; Thu, 27 Jan 2011 16:21:07 +0100 Message-ID: <4D418D62.4010906@techbaza.pl> Date: Thu, 27 Jan 2011 16:21:06 +0100 From: Piotr Czekalski Organization: TECHBAZA.PL User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; pl; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6 ThunderBrowse/3.3.2 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: how to get row number in select query References: <4D4047C1.5030208@encs.concordia.ca> <4D4181E9.2000305@encs.concordia.ca> <090BC28FACC442EAA5D46B58F55480AE@marktestcr.marktest.pt> In-Reply-To: <090BC28FACC442EAA5D46B58F55480AE@marktestcr.marktest.pt> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201101/105 X-Sequence-Number: 35052 Gentelmen, I follow this thread and I don't exactly get an idea of yours, but isn't is as simple as (example: table "web.files" contains one column named "fileurl" ): select row_number() over(), X.fileurl from (select fileurl from web.files order by fileurl) X The only disadvantage is that if you do want to order resultset you have to use "select from select" as numbers are added before order which may cause some performance troubles. Regards, Piotr -- -------------------------------------------------------------- "TECHBAZA.PL" Sp. z o.o. Technologie WEB, eDB& eCommerce OddziaƂ Gliwice ul. Chorzowska 50 44-100 Gliwice tel. (+4832) 7186081 fax. (+4832) 7003289