Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id C9CC6632F0E for ; Thu, 25 Feb 2010 10:42:59 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 98928-09 for ; Thu, 25 Feb 2010 14:42:48 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 34F3C632EDD for ; Thu, 25 Feb 2010 10:42:49 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o1PEgkVh002799; Thu, 25 Feb 2010 09:42:46 -0500 (EST) To: "Julien Theulier" cc: "'Mose'" , "'Dave Crooke'" , "'pgsql-performance'" Subject: Re: Extracting superlatives - SQL design philosophy In-reply-to: <000c01cab5fb$d03e4100$70bac300$@com> References: <9eb6f9411002241350m4532305ai88c5640f0e3dd864@mail.gmail.com> <000c01cab5fb$d03e4100$70bac300$@com> Comments: In-reply-to "Julien Theulier" message dated "Thu, 25 Feb 2010 10:20:45 +0100" Date: Thu, 25 Feb 2010 09:42:46 -0500 Message-ID: <2798.1267108966@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/356 X-Sequence-Number: 37777 "Julien Theulier" writes: > Teradata provides a “qualify” syntax which works as a filtering condition on > a windowed function result. This is the only DB allowing this direct > filtering on windowed functions, from what I know. Seems like you could easily translate that into SQL-standard syntax by adding a level of sub-select: select ... from (select *, window_function wf from ...) ss where wf=1; regards, tom lane