X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2A17C5E3F15 for ; Fri, 20 Aug 2004 13:53:17 -0300 (ADT) 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 94682-08 for ; Fri, 20 Aug 2004 16:53:22 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id D75475E3639 for ; Fri, 20 Aug 2004 13:53:12 -0300 (ADT) Received: (qmail 27189 invoked by uid 500); 20 Aug 2004 17:01:48 -0000 Date: Fri, 20 Aug 2004 12:01:48 -0500 From: Bruno Wolff III To: David Garamond Cc: pgsql-sql@postgresql.org Subject: Re: olympics ranking query Message-ID: <20040820170148.GB26674@wolff.to> Mail-Followup-To: David Garamond , pgsql-sql@postgresql.org References: <41262968.2000507@zara.6.isreserved.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41262968.2000507@zara.6.isreserved.com> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/229 X-Sequence-Number: 18726 On Fri, Aug 20, 2004 at 23:40:08 +0700, David Garamond wrote: > > Challenge question: is there a simpler way to do query #1 (without any > PL, and if possible without sequences too? You could use a subselect to count how many countries had a lower medal ranking and add 1 to get the rank. This should be a lot more standard than using sequences. It will probably be a little slower, but for tables of that size it shouldn't be a big deal.