Re: SQL Question

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

Ok but you haven't specify that and in your example there is no similar use

one solution is to change LastUpdate type and use timestamp.

to insert you make :
insert into test."tableProd" values (100, '2004-05-01 02:52:12') but it exists other format for time....see postgresql doc for different type (here the french version http://traduc.postgresqlfr.org/pgsql-fr/datatype-datetime.html)

With timestamp the accuracy is better, you have until second.

-----Message d'origine-----
De : Richard Huxton [mailto:dev(at)archonet(dot)com]
Envoy : vendredi 15 avril 2005 15:42
: GIROIRE, Nicolas (COFRAMI)
Cc : Alex; pgsql-general(at)postgresql(dot)org
Objet : Re: [GENERAL] SQL Question

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

This mail has originated outside your organization,
either from an external partner or the Global Internet.
Keep this in mind if you answer this message.

This e-mail is intended only for the above addressee. It may contain
privileged information. If you are not the addressee you must not copy,
distribute, disclose or use any of the information in it. If you have
received it in error please delete it and immediately notify the sender.
Security Notice: all e-mail, sent to or from this address, may be
accessed by someone other than the recipient, for system management and
security reasons. This access is controlled under Regulation of
Investigatory Powers Act 2000, Lawful Business Practises.

Browse pgsql-general by date

  From Date Subject
Next Message Mario Weilguni 2005-04-15 14:23:56 PostgreSQL Database cluster with multiple different locale settings?
Previous Message Richard Huxton 2005-04-15 13:41:41 Re: SQL Question