Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id D8E136322F0 for ; Tue, 22 Sep 2009 06:50:15 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 18579-06 for ; Tue, 22 Sep 2009 09:49:59 +0000 (UTC) X-Greylist: delayed 00:05:01.626271 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 EE671632587 for ; Tue, 22 Sep 2009 06:50:04 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by sargon.lncsa.com (Postfix) with ESMTP id 4BCA13015E29 for ; Tue, 22 Sep 2009 11:45:01 +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 OV61LBZnIrgB for ; Tue, 22 Sep 2009 11:45:01 +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 2ACA83015E24 for ; Tue, 22 Sep 2009 11:45:01 +0200 (CEST) Received: from galba.apartia.fr (galba.apartia.fr [10.0.3.119]) by zenon.apartia.fr (Postfix) with ESMTP id DBD6C5B93F8CA for ; Tue, 22 Sep 2009 11:44:57 +0200 (CEST) Received: by galba.apartia.fr (Postfix, from userid 1000) id AFD1A1D434; Tue, 22 Sep 2009 11:44:57 +0200 (CEST) Date: Tue, 22 Sep 2009 11:44:57 +0200 From: Louis-David Mitterrand To: pgsql-sql@postgresql.org Subject: selecting latest record Message-ID: <20090922094457.GA24885@apartia.fr> Mail-Followup-To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.74 tagged_above=-10 required=5 tests=BAYES_20=-0.74 X-Spam-Level: X-Archive-Number: 200909/100 X-Sequence-Number: 33165 Hi, I have a simple table price(id_product, price, date) which records price changes for each id_product. Each time a price changes a new tuple is created. What is the best way to select only the latest price of each id_product? Thanks,