From: Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org>
To: pgsql-sql@postgresql.org
Subject: Re: selecting latest record
Date: Tue, 22 Sep 2009 12:02:32 +0200
Message-ID: <20090922100232.GA26478@apartia.fr> (raw)
In-Reply-To: <162867790909220256k3865e0dcr742163d7828573c8@mail.gmail.com>
References: <20090922094457.GA24885@apartia.fr>
<162867790909220256k3865e0dcr742163d7828573c8@mail.gmail.com>
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,
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: vindex+lists-pgsql-sql@apartia.org
Subject: Re: selecting latest record
In-Reply-To: <20090922100232.GA26478@apartia.fr>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox