Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id C141B6322F6 for ; Tue, 22 Sep 2009 07:02:43 -0300 (ADT) 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 18377-07 for ; Tue, 22 Sep 2009 10:02:35 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sargon.lncsa.com (mail.lncsa.com [213.215.8.2]) by mail.postgresql.org (Postfix) with ESMTP id E1E326322F0 for ; Tue, 22 Sep 2009 07:02:35 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by sargon.lncsa.com (Postfix) with ESMTP id 3CDCE300EB1A for ; Tue, 22 Sep 2009 12:02:33 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at lncsa.com Received: from sargon.lncsa.com ([127.0.0.1]) by localhost (sargon.lncsa.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2lG-TT95x1Yq for ; Tue, 22 Sep 2009 12:02:33 +0200 (CEST) Received: from zenon.apartia.fr (zenon.apartia.fr [10.0.3.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "zenon.apartia.fr", Issuer "ca.apartia.fr" (verified OK)) by sargon.lncsa.com (Postfix) with ESMTP id 1A2CF3015E29 for ; Tue, 22 Sep 2009 12:02:33 +0200 (CEST) Received: from galba.apartia.fr (galba.apartia.fr [10.0.3.119]) by zenon.apartia.fr (Postfix) with ESMTP id 8BBEF5B93F8CA for ; Tue, 22 Sep 2009 12:02:32 +0200 (CEST) Received: by galba.apartia.fr (Postfix, from userid 1000) id 6E4D31D434; Tue, 22 Sep 2009 12:02:32 +0200 (CEST) Date: Tue, 22 Sep 2009 12:02:32 +0200 From: Louis-David Mitterrand To: pgsql-sql@postgresql.org Subject: Re: selecting latest record Message-ID: <20090922100232.GA26478@apartia.fr> Mail-Followup-To: pgsql-sql@postgresql.org References: <20090922094457.GA24885@apartia.fr> <162867790909220256k3865e0dcr742163d7828573c8@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <162867790909220256k3865e0dcr742163d7828573c8@mail.gmail.com> User-Agent: Mutt/1.5.20 (2009-06-14) 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: 200909/102 X-Sequence-Number: 33167 On Tue, Sep 22, 2009 at 11:56:54AM +0200, Pavel Stehule wrote: > > there are more ways - depends on what you wont. > > one way is > > SELECT * > FROM price > WHERE (id_product, date) = (SELECT id_product, max(date) > FROM price > GROUP BY > id_product) Nice. I didn't know one could have several args in a single WHERE clause. Thanks,