Re: SQL Question

From: Richard Huxton <dev(at)archonet(dot)com>
To: "GIROIRE, Nicolas (COFRAMI)" <nicolas(dot)giroire(at)airbus(dot)com>
Cc: Alex <alex(at)meerkatsoft(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: SQL Question
Date: 2005-04-15 13:41:41
Message-ID: 425FC495.9050203@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

GIROIRE, Nicolas (COFRAMI) wrote:
> For the first request (How can i select only the newest record for each ProdId ?), you can do :
>
> select * from test."tableProd" u
> where u."LastUpdate" = (select max(t."LastUpdate")
> from test."tableProd" t
> where u."ProdId" = t."ProdId")

Although this only guarantees one row if LastUpdate is unique for every
ProdId.
--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message GIROIRE, Nicolas (COFRAMI) 2005-04-15 13:56:40 Re: SQL Question
Previous Message Alvaro Herrera 2005-04-15 12:48:41 Re: If statements on select