Re: SQL Question - Mailing list pgsql-general

From Richard Huxton
Subject Re: SQL Question
Date
Msg-id 425FC495.9050203@archonet.com
Whole thread Raw
In response to Re: SQL Question  ("GIROIRE, Nicolas (COFRAMI)" <nicolas.giroire@airbus.com>)
List 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

pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: If statements on select
Next
From: "GIROIRE, Nicolas (COFRAMI)"
Date:
Subject: Re: SQL Question