pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: GIROIRE, Nicolas (COFRAMI) <nicolas.giroire@airbus.com>
Cc: Alex <alex@meerkatsoft.com>
Cc: pgsql-general@postgresql.org
Subject: Re: SQL Question
Date: Fri, 15 Apr 2005 14:41:41 +0100
Message-ID: <425FC495.9050203@archonet.com> (raw)
In-Reply-To: <5C40CD1E4697424ABDE3AC57CF1B22C62772B0@FR0-MAILMB20.res.airbus.corp>
References: <5C40CD1E4697424ABDE3AC57CF1B22C62772B0@FR0-MAILMB20.res.airbus.corp>

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



view thread (71+ messages)  latest in thread

Message-ID: <425FC495.9050203@archonet.com>
Permalink:  ../425FC495.9050203@archonet.com/
Also on:    postgresql.org/message-id/425FC495.9050203@archonet.com

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: dev@archonet.com, nicolas.giroire@airbus.com, alex@meerkatsoft.com
  Subject: Re: SQL Question
  In-Reply-To: <425FC495.9050203@archonet.com>
  References: <5C40CD1E4697424ABDE3AC57CF1B22C62772B0@FR0-MAILMB20.res.airbus.corp> <425FC495.9050203@archonet.com>

* 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